1

When trying to select from 'jREwardToysRUs.dbo.MailDetail_198' table from jREwardToysRUs DataBase, I am getting the following error:

Invalid object name 'jREwardToysRUs.dbo.MailDetail_198'

Like below :

select top 10 *
from jREwardToysRUs.dbo.MailDetail_198

but giving [], the error is gone.Like:

select top 10 *
from [jREwardToysRUs.dbo.MailDetail_198]

Please suggest. how to remove error while selecting only with table name?

3
  • 2
    Tried to read the question, now I am blind. Commented Feb 14, 2018 at 16:53
  • 2
    @ErayBalkanli And now you can see again! :) Commented Feb 14, 2018 at 16:56
  • When quoting objects in SQL Server, you need to quote each object separately. So, when using 3 part naming conventions DatabaseName.SchemaName.TableName would become [DatabaseName].[SchemaName].[TableName]. If you encapulate the whole thing, the Query analyser would look for a database object literally called 'DatabaseName.SchemaName.TableName' within the database you are currently connected to. Commented Feb 14, 2018 at 17:09

1 Answer 1

1

I think you are looking for "use" keyword:

use [jREwardToysRUs]
go

select top 10 * 
from [dbo].[MailDetail_198]
Sign up to request clarification or add additional context in comments.

1 Comment

No the entire jREwardToysRUs.dbo.MailDetail_198 is the table name. So to use this in SQL,enclose them with [Table Name]. Like below: select top 10 * from [jREwardToysRUs.dbo.MailDetail_198]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.