August 25, 2008 at 1:00 pm
Select * from [tablename] works but select * from tablename does not work....how to fix this?
August 25, 2008 at 1:06 pm
What is the table name here? Is it a sql reserved keyword?
MJ
August 25, 2008 at 1:10 pm
No it is not a reserved keyword...It is same for all the tables on a particular database.
August 25, 2008 at 1:22 pm
I suspect it has do to something with database collation. Also, check sys.objects view results to verify the tablenames there.
Are they having [] in their name in sys.objects too?
MJ
August 25, 2008 at 1:26 pm
on sysobject it is having name as tablename not as [tablename] or "tablename"
I forget to mention that it also works if we do select * from "tablename"
August 25, 2008 at 1:30 pm
Can you give us a few table names for tables where this occurs?
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
August 25, 2008 at 1:40 pm
table names are,
emp
msa
reports
users
users_groups
users_groups_rel
xref...
etc..etc..etc...
August 25, 2008 at 1:58 pm
Is this database migrated or came from Microsoft Access?
MJ
August 25, 2008 at 2:59 pm
RPSql (8/25/2008)
Select * from [tablename] works but select * from tablename does not work....how to fix this?
Please define "works" and "does not work".
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
August 25, 2008 at 8:39 pm
hi,
chek out the status of quoted_identifier
August 26, 2008 at 12:11 am
Yeah I echo Ramesh..this has something to do with "QUOTED IDENTIFIER"
Check if the "QUOTED IDENTIFIER" is set to ON and then set it back to OFF
SET QUOTED_IDENTIFIER OFF
GO
-Rajini
August 26, 2008 at 12:42 am
I don’t know what causes this behavior, but I don’t think that it has something to do with the QUOTED IDENTIFIER set option. The reason I don’t think so is that when this option is set to on, then you can use double quotation marks to identify the objects, but you don’t have to use it. This is not the behavior that rpSQL wrote.
Few questions about this behavior:
1) Do you get the same behavior from each session or are there sessions that you don’t have to use delimiters to surround the tables’ name?
2) If there are sessions that you don’t need to use delimiters can you write a bit more about it (for example it happens only for a specific login, or it happens only from a specific machine etc’)
3) When you say that select * from tablename doesn’t work – what do you mean? Do you get an error message? If so, can you post the error message?
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
August 26, 2008 at 6:24 am
Adi
Answers:
1) I get same behavior for all the sessions by sql ids as well as windows authentication id that have all the permission..i also tried with "sa" user.
2) refer answer 1.
3) It doesn't work means, if suppose the following is my query
select * from emp
then o/p is
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'emp'.
now if I do select * from [emp]
OR
select * from "emp"
then it gives output and writes all the rows of table as o/p.
Thanks
August 26, 2008 at 6:31 am
RPSql (8/26/2008)
Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'emp'.
Ah, OK. You see "Incorrect syntax" is a much different error than "Invalid object name."
Hmmm...
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
August 26, 2008 at 7:11 am
I wonder what would happen if you prefix the table name with the schema and did not use the square brackets.
I'm not sure what that would prove, just curious.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply