March 1, 2012 at 9:20 am
Hi All,
I have dynamic sql where the @sql variable is defined as nVarChar(MAX). I am passing in a long comma
delimited string to the SProc. When I run the SP, it error out. For example, My string is "6842,109620,158
583,6843,...."
So the error message is incorrect syntax near 158, because the string may be putting a line break after 158 and it is suppose to be
158583.
How can I resolve this?
Thanks.
March 1, 2012 at 9:29 am
Can you provide a bit more detail? Can you post some of the code and perhaps the actual string?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 1, 2012 at 9:32 am
All of you must be wondering, what is this person talking about? It was my silly mistake. I tried running the SP using a long string
of comma delimited string along with other parameters. But I pressed the enter key in the middle of the number, so certainly it would
give me that error. Sorry to bother all. Problem resolved by keeping the number together.
Thanks.
March 1, 2012 at 9:33 am
LOL glad you figured it and thanks for posting back.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply