Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
keanhoo168
Starting Member
2 Posts |
Posted - 2010-04-13 : 03:43:20
|
I have a table with a field named "USER" in the table.When i issue a query SELECT * FROM table WHERE user = 'ABC',it always show me all the data in the table.When i check through the reserved word list, i found that 'USER' itself is a reserved word in SQL.How should i modify my query statement so that i get the result i want?Thank you. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-13 : 04:39:44
|
TrySELECT * FROM table WHERE [user] = 'ABC'If that is not the solution then show your original query please. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-04-13 : 04:45:04
|
by defaultSELECT user returns the schema name. (if I run this on my db I get 'dbo' returned. The following SQL returns all rows in @foo for exampleDECLARE @foo TABLE ( [user] VARCHAR(255) )INSERT @foo ([user]) SELECT 'abc'UNION SELECT 'def'SELECT * FROM @fooSELECT * FROM @foo WHERE user = 'abc'SELECT * FROM @foo WHERE user = 'dbo' Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-13 : 05:01:08
|
That's interesting - so the square brackets should bring the solutuion. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
keanhoo168
Starting Member
2 Posts |
Posted - 2010-04-13 : 21:07:04
|
I try SELECT * FROM qgpl.zsu WHERE [user] = 'abc';The result i get is following error:[SQL0104] Token [ was not valid. Valid tokens: ( + - ? : DAY NOT RRN CASE CAST CHAR DAYS HOUR LEFT TRIM USER.Any escape character can be used in this case? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-13 : 23:21:40
|
quote: Originally posted by keanhoo168 I try SELECT * FROM qgpl.zsu WHERE [user] = 'abc';The result i get is following error:[SQL0104] Token [ was not valid. Valid tokens: ( + - ? : DAY NOT RRN CASE CAST CHAR DAYS HOUR LEFT TRIM USER.Any escape character can be used in this case?
Looks like you are not using Microsoft SQL Server 2000. Googling on the error message leads to DB2. This is a Microsoft SQL Server forum. Try posting your question over at a DB2 forum. KH[spoiler]Time is always against us[/spoiler] |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|