How to insert data from one db to another db with same sql server ?

  • Hi

    How to insert data from one db to another db with same sql server ?

    I am having a schema TEST with table as EMP

    I need to select values from TEST.EMP and INSERT INTO

    TEST1.EMPLOYEE. TEST1 is different schema, both are available in same server.

    Regards

  • you can use the import/export wizards.

    Right click on the database--> Tasks --> Import data.

    Or write a sql INSERT statement and use the Three part naming convention for the table on the other database.

    eg'

    Insert into TEST1.EMPLOYEE

    Select *

    From [TEST].[dbo].[EMP]

  • Hi

    It shows invalid object name

    TEST1.EMPLOYEE

  • Are you running the statement from the database where test1.emp is? Sounds to me that you're in the wrong DB at the time....

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • As Matt said, check what database you are running this on.

    Also I only wrote the SQL from the little information that was given, if you provide the table structures and exact db and table names I could provide a more complete solution.

  • Thanks steve

    It works..

    I had changed as follows..

    Insert into [TEST1].[dbo].EMPLOYEE

    Select *

    From [TEST].[dbo].[EMP]

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

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