Reputation: 205
I have a query with tons of inner join and left outer join. 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?
Upvotes: 1
Views: 3694
Reputation: 205
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.
Upvotes: 0
Reputation: 2626
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", " ");
Upvotes: 0
Reputation: 46485
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.
Upvotes: 3
Reputation: 887
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.
Upvotes: 0