I have the table name which is in the linked server.How to write a T-SQL query to find the database name (In linked server) from that table name?
I have no idea about linked server querying.Kindly help me
Thank you.
Asked
Active
Viewed 1,202 times
1
-
If you know it's SQL Server why did you tag mysql... Please use the correct tags. Also, this information is easily found via google. – Jacob H Jul 27 '17 at 13:56
-
Sorry for that Jacob – Sana Jul 27 '17 at 13:58
3 Answers
1
SELECT * FROM <linkedservername>.INFORMATION_SCHEMA.TABLES
or
SELECT * FROM <linkedservername>.INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'XXXXX'
or
select * from <linkedservername>.master.sys.databases
for get a list of all Databases

Frank
- 1,901
- 20
- 27
0
SELECT * FROM LinkServerName.DatabaseName.SchemaName.TableName
Example
Select * from MYLINKSERVER.MYDATABASE.MYSCHEMA.MYTABLE

Arun Vishwakarma
- 1
- 3