SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Retrieve Part of the Filename stored in a variable


Retrieve Part of the Filename stored in a variable

Author
Message
divyanth
divyanth
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1733 Visits: 556
Hi

I am using a Foreach loop container and in the derived column im trying to retrieve only the Filename but when I use the variable which actualy stores the Filename I also get the path of the File For example If a use a variable in the derived column expression I get the following Output C:\Data\Loop\Filesame.xls but I only need the file name i.e., name... How do i do that .. I have tried using Name only option in the For each Enumerator but it gives me error asking me to check if the Worksheet Name [Excel Source [122]] Error: Opening a rowset for "New$" failed. Check that the object exists in the database.
ArkWare
ArkWare
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 1741
Hey Danny,

one way to get the file name only would be to create another variable. set it's property, EvaluateAsExpression to True. Then enter the following expression:


REVERSE(SUBSTRING( REVERSE(@[User::filename]),1, FINDSTRING( REVERSE(@[User::filename]) , "\\", 1 ) -1))



replace the @[User::filename] variable in the sample code with your variable that is being populated by the ForEachFile loop.

ArkWare
divyanth
divyanth
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1733 Visits: 556
Thanks a lot dude!!!!
ArkWare
ArkWare
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 1741
No Problem, Dude

Expressions are your friend.. Cool

ArkWare
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search