Tuesday, February 14, 2012

Char(10) breaking query

I have been working on a pretty ugly stored procedure recently, while debugging I added a char(10) to the end of each line of the SQL query so I could copy it to query analyzer(QA) and debug the SQL syntax output from of the stored procedure.

It had no effect on the stored procedure working, but when I copied the query to QA it got the error below, so I removed them all and added them in one line at a time to find the problem.

--Server: Msg 170, Level 15, State 1, Line 3
--Line 3: Incorrect syntax near ','.

Below are the 2 querys, the only difference is the Char(10) between Amt6 and Amt7!

http://www.rakbiz.com/download/broken.txt
http://www.rakbiz.com/download/working.txt

I also tried char(13) with same results.

any ideas why this is happening or how to add line breaks for readability without this problem?

Thanks for your help!Why is the code all on 1 line?

Ir's generated code isn't it.

Kind of hard to debug it without being formatted...|||You've been living in the *nix world too long! Windoze uses CRLF (aka Char(13) + Char(10) in SQL) instead of just LF (Char(10), aka NewLine) to separate lines.

-PatP|||Thanks Pat for the tip, that was it, I would never have guessed!

Actually I am from *ax backgroup ;)

No comments:

Post a Comment