SSIS - The expression cannot be parsed because it contains invalid elements at the location specified

If you get the following error when trying to write an expression there is an easy solution

Attempt to parse the expression "@[User::FilePath] + "\" + @[User::FileName] + ".raw"" failed.  The token "." at line number "1", character number "<some position>" was not recognized. The expression cannot be parsed because it contains invalid elements at the location specified.

The SSIS expression language is a C based language and the \ is a token, this means you have to escape it with another one. i.e "\" becomes "\\", unlike C# you can't prefix the string with a @, you have to use the escaping route.

In summary when ever you want to use \ you need to use two \\


Published 04 March 2010 09:56 by simonsabin

Comments

05 March 2010 03:26 by SqlServerKudos

# SSIS - character number "81" was not recognized

Kudos for a great Sql Server article - Trackback from SqlServerKudos

06 March 2010 03:26 by SqlServerKudos

# SSIS - The expression cannot be parsed because it contains invalid elements at the location specified

Kudos for a great Sql Server article - Trackback from SqlServerKudos