Select * from [tablename] works but select * from tablename does not work....how to fix this?

  • I am sorry I also forget to mention this....

    I tried

    select * from dbo.emp

    select * from dbo.EMP

    select * from emp

    select * from EMP

    but it gives the same output like this...

    Msg 156, Level 15, State 1, Line 1

    Incorrect syntax near the keyword ''.

  • isn't this an interesting one.

    Is this contained to one database, or all on the server?

    Same on the master db?

    Does the same thing happen when you run your query using a query different tool?

    use query analyzer or SSMS (something different)..

  • Hang on here.

    The error message indicates that SQL server thinks the table name is a keyword. Putting square brackets around the table name, or as SQL Server sees it, around the keyword, tells SQL server it's not a keyword.

    Now the new question is why does SQL Server think the table names are keywords?



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    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]

  • RPSql,

    I have a friend who is trying to figure this one out. He would like to know what database roles are available in the database(s) with the problem?



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    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 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply