Getting data from table on other database

  • Can I insert data from a table which is on other database on the same server through query, Like I want to insert data from master.employee table into northwind.employee table. I have tried this but fail:

    insert into master.employee from northwind.employee

    thanx in advance

  • use linked server or OPENROWSET to insert the data, for more info see SQL BOL.

  • Is it not possible with linked server. becoz i want to do this with simple query.

  • If on same server nothing wrong You are just missing fully qualified name. In your case schema 🙂

    something like master.dbo.employee

  • ok thnx this was permission problems that is y the query not working...

  • For real?

    "insert into master..SomeUserTable"

  • faiz_ku (5/26/2009)


    Can I insert data from a table which is on other database on the same server through query, Like I want to insert data from master.employee table into northwind.employee table. I have tried this but fail:

    insert into master.employee from northwind.employee

    thanx in advance

    If both the databases on the same server then you just need to refer the objects using three-part naming convention. For e.g.

    INSERT EmployeeDB.dbo.Employees SELECT * FROM Northwind.dbo.Employees

    --OR

    INSERT EmployeeDB..Employees SELECT * FROM Northwind..Employees

    --Ramesh


Viewing 7 posts - 1 through 6 (of 6 total)

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