| Author |
Topic |
|
domnet
Starting Member
1 Post |
Posted - 2011-12-09 : 11:36:10
|
| Please I have problem to extract row from MS SQL 2005 database with WHERE syntaxt. For example this does not work at all strSQL = "SELECT * FROM tblUsers WHERE User='John' " |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-09 : 11:54:44
|
| why it doesnt work? do you've record for John in tblUsers table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
anita.86
Starting Member
21 Posts |
Posted - 2011-12-09 : 23:19:46
|
| remove double quotesuse this query:SELECT * FROM tblUsers WHERE User='John' N/A |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-10 : 07:41:23
|
quote: Originally posted by anita.86 remove double quotesuse this query:SELECT * FROM tblUsers WHERE User='John' N/A
OP might be using it inside some web application language which is why i guess the ""------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-12-12 : 04:56:37
|
quote: Originally posted by domnet Please I have problem to extract row from MS SQL 2005 database with WHERE syntaxt. For example this does not work at all strSQL = "SELECT * FROM tblUsers WHERE User='John' "
User is a keyword in SQL Server. Try using [user] insteadMadhivananFailing to plan is Planning to fail |
 |
|
|
sunnyleoneo
Starting Member
19 Posts |
Posted - 2011-12-12 : 06:13:53
|
| I think User Column name conflicts with T-SQL clause keyword, Wrap the column name in brackets. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-12-15 : 03:15:25
|
quote: Originally posted by sunnyleoneo I think User Column name conflicts with T-SQL clause keyword, Wrap the column name in brackets.
Yes this is what I said in my previous replyMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-15 : 03:23:18
|
quote: Originally posted by madhivanan
quote: Originally posted by sunnyleoneo I think User Column name conflicts with T-SQL clause keyword, Wrap the column name in brackets.
Yes this is what I said in my previous replyMadhivananFailing to plan is Planning to fail
Dont worry too much on thatThats one of those echo bots in action As Don says:Please mark the answer as accepted and move on------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2011-12-15 : 05:50:03
|
yeah that's pretty pernicious:DECLARE @foo TABLE ( [user] VARCHAR(15) )INSERT @foo ([user]) VALUES ('barney'),('fred')SELECT USER FROM @fooSELECT * FROM @foo WHERE USER = 'barney'SELECT * FROM @foo WHERE [user] = 'barney'All the selects are *valid* code (they all work)but they give totally different answers.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|