开发者

\t comes out in SQL Query

I have a query with tons of inner join and left outer j开发者_运维问答oin. It runs perfectly and gives me the result I want in SQL Management Studio. But when I run the .cs file, the string value of that query includes "\t" in some places like in front of the words "INNER JOIN". I did check the spacing between key words and all syntax are correct. Does anybody know when these "\t" things come from?


In the debugger in Visual Studio, tabs will be shown as \t - this doesn't mean that SQL Server will not understand the syntax, it is just how the debugger displays special characters.


You might want to check the query in your cs code again to ensure you have not used \t anywhere. I don't think it will be inserted automatically in any case.

It is a good practice to use stored procedures instead of inline queries, so you might want to try using a stored procedure instead.


If you can't find where the TAB characters ('\t') are coming from and they are causing problems you can replace them with spaces before executing the query:

var query = "SELCET * FROM MyTable";
query = query.Replace("\t", " ");


Yap, thanks to ypercube and kaps. It has been solved. Because I copied the whole chunk of query from SQL Management studio to .cs file. I deleted those line with "\t" and typed it again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜