TOKEN and TOKENCOUNT are new string functions introduced from SSIS 2012 .
As mentioned in MSDN :
TOKEN - Returns a token (substring) from a string based on the specified delimiters that separate tokens in the string and the number of the token that denotes which token to be returned.
Syntax :
Example : (To extract filename from file path using TOKEN and TOKENCOUNT )
Below expression returns 3 , because delimiter_string "\\" splits the character_expression
"G:\\GAMES\\fifa.exe" into three parts .
TOKENCOUNT("G:\\GAMES\\fifa.exe", "\\")
Below expression returns fifa.exe , because delimiter_string "\\" splits the character_expression "G:\\GAMES\\fifa.exe" into three parts, Occurrence is specified as 3, so the third token in the string is returned.
TOKEN("G:\\GAMES\\fifa.exe", "\\",3)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi16iXw30vHJc4mu7izuDh6a8gtmyWpL4Cnhwg0NWSr32p7DyHTqNeFz00RIZfEfXOi39I4MW0_2IpldZnsPZcD2R5RHfBQlluuVjKFCdkkpv0ErmaKG-GjYxnraz12LkppsmgsAcxsy0S4/s640/2.JPG)
To extract filename from file path using TOKEN and TOKENCOUNT
TOKEN("G:\\GAMES\\fifa.exe", "\\", TOKENCOUNT("G:\\GAMES\\fifa.exe", "\\"))
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX4_n9oDs3a276iG6uB4a-1ezdp6dyqYyJ6Leu1w498nOX8OAg8e7CbrUA80iuzqaDLFmE9vXDtRmJAGCjUS79GZcO2IGcXXq1Grbt_F8Txq9SF4VBfh62VKuo1DueU-34tsfiPjGsiA0L/s640/3.JPG)
For more info & examples :
Token - http://technet.microsoft.com/en-us/library/hh213216.aspx
TokenCount - http://technet.microsoft.com/en-us/library/hh213135.aspx
As mentioned in MSDN :
TOKEN - Returns a token (substring) from a string based on the specified delimiters that separate tokens in the string and the number of the token that denotes which token to be returned.
Syntax :
TOKEN(character_expression, delimiter_string, occurrence)
TOKENCOUNT - Returns the number of tokens in a string that contains tokens
separated by the specified delimiters.
Syntax :
TOKENCOUNT(character_expression, delimiter_string)
Example : (To extract filename from file path using TOKEN and TOKENCOUNT )
Below expression returns 3 , because delimiter_string "\\" splits the character_expression
"G:\\GAMES\\fifa.exe" into three parts .
TOKENCOUNT("G:\\GAMES\\fifa.exe", "\\")
Below expression returns fifa.exe , because delimiter_string "\\" splits the character_expression "G:\\GAMES\\fifa.exe" into three parts, Occurrence is specified as 3, so the third token in the string is returned.
TOKEN("G:\\GAMES\\fifa.exe", "\\",3)
To extract filename from file path using TOKEN and TOKENCOUNT
TOKEN("G:\\GAMES\\fifa.exe", "\\", TOKENCOUNT("G:\\GAMES\\fifa.exe", "\\"))
For more info & examples :
Token - http://technet.microsoft.com/en-us/library/hh213216.aspx
TokenCount - http://technet.microsoft.com/en-us/library/hh213135.aspx
2 comments:
good post, just what i needed. thanks :)
good post, just what i needed - thanks :)
Post a Comment