-
June 22nd, 2010, 08:37 AM
#1
SQL Select Statement
I'm trying to pass a SQL statement through C# but my SQL statement needs quotes around a table since the name of the table is also a proper SQL command(which I have no control over).
Looking at MSDN I tried the following two methods but.
string sqlSELECT = @"select * FROM tableNAME.""SELECT"";
string sqlSELECT = "select * FROM tableNAME./"SELECT/"";
The problem is that both of these statements above leave in slashes.
-
June 22nd, 2010, 08:53 AM
#2
Re: SQL Select Statement
They should be backslashes...
Code:
string sqlSELECT = @"select * FROM tableNAME.\"SELECT\"";
... but the sql looks weird at all.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
June 22nd, 2010, 08:59 AM
#3
Re: SQL Select Statement
Whoops meant to put backslashes in but still the end result will come out with slashes in the SQL statement.
-
June 22nd, 2010, 09:03 AM
#4
Re: SQL Select Statement
use [ ] around reserved words or names that contain spaces in your sql string
Select * from [Select] where [User Name] = ....
Always use [code][/code] tags when posting code.
-
June 22nd, 2010, 12:44 PM
#5
Re: SQL Select Statement
Thats what their called, reserved words, had I remember that would have solved this without assistance.
Thanks you though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|