insert rows in another database

  • Hi,

     

    I want to insert rows from  table1 to table2, table1=table2, but table2 is on a diferent database……

     

    I thought the following instruction would resolve this:

     

    insert into DB1.dbo.table1

    select * from DB2.dbo.table2  where ID=’X’'

     

    but  DB2 is not recognized..even if I use DB1, DB2 or master…..

     

    How can I do this ?

     

    Thanks for you reply...

  • What is the error? Check your login has sufficient access rights in DB2.

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant

  • Hi,

     

    The error is:

    insert into aks_le2.dbo.artigos

    select * from aks_le.dbo.artigos where numartigo='1900'

    Server: Msg 208, Level 16, State 1, Line 1

    Invalid object name 'aks_le2.dbo.artigos'.

  • if aks_le Db is on the same server, then it is definitely the access/rights issue with your Login on aks_le.

     

  • The error tells me that in the database aks_le2 there is not an object named artigos or the aks_le2 database doesn't exists on the same instance of SQL Server.

    Most likely it is due to DB / table ownership or permissions, but sometimes KISS comes into play.

     

    -

Viewing 5 posts - 1 through 4 (of 4 total)

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