How to get the data from linked servers using queries How to get the data from linked servers using queries sql-server sql-server

How to get the data from linked servers using queries


I think you should change the name of the linked server, as the - char is reserved in SQL.

You could try surrounding the name with brackets, but it becomes boring

Also, you should include the schema name in the query, or double point to use the default one:

so, you can try:

select * from [ravikiran-vm].kiran.dbo.employselect * from [ravikiran-vm].kiran..employ

Or whatever your schema be.


You have to use OPENQUERY:

SELECT * FROM OPENQUERY([ravikiran-vm],'SELECT * FROM KIRAN..EMPLOY')


to get data from linked server you use 4 part notationServer.Database.Schema.Table

since you have an invalid character in your name(-) you need to add brackets around the name

select * from [ravikiran-vm].kiran..employ

You probably also don't want all the data returned