sql server query

PeterBaileyUk
PeterBaileyUk used Ask the Experts™
on
What s the query syntax to query a table from another db.  am currently n a db named ClentData where some tables resse but  also want to get to a table n a bd called dctonery(sorry lost a letter on my keyboard)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
Try this
SELECT * FROM DATABASENAME.SCHEMA.TABLENAME

Open in new window

so in your case should be
SELECT * FROM dctonery.dbo.n

Open in new window

The schema dbo is just an assumption because its very common...

Author

Commented:
I think this is what you meant but it says it cannot find the object name

use clientdata
go

SELECT * FROM dictionery.[dbo].[TblCurrentWords]

Open in new window

John TsioumprisSoftware & Systems Engineer

Commented:
Does your account has permissions to use this database...?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
objects
here is a screenshot of the structure

Author

Commented:
yes I have the permissions as I created both dbs
Software & Systems Engineer
Commented:
How about making a select on dictionery database...strange...
John TsioumprisSoftware & Systems Engineer

Commented:
As a workaround because maybe something is not as it seems ....go to DevART and download dbForge SQL Complete, v5.5 Express...after you install this you will have intellisense when you are doing queries and it will show you the proper syntax...

Author

Commented:
this worked:

so I guess that proves the permissions

--use clientdata
--go

--SELECT * FROM dictionery.[dbo].[TblCurrentWords]

use Dictionary


SELECT * FROM [dbo].[TblCurrentWords]

Open in new window

John TsioumprisSoftware & Systems Engineer

Commented:
How about right clicking your Dictionary database and Refresh
EDIT: have you tried to match exactly the case ...i see Dictionary working but...dictionary is lowercase
maybe your server collation is case sensitive...so lowercase <> uppercase

Author

Commented:
thank you the tool you suggested got me to the correct 'way'

use ClientData

SELECT * FROM Dictionary.dbo.TblCurrentWords
John TsioumprisSoftware & Systems Engineer

Commented:
So i guess it was case sensitive issue...
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
You just got a typo in your select:
SELECT * FROM dictionery.[dbo].[TblCurrentWords]

Should be 'a' instead of 'e'.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial