Tech Off Post

Single Post Permalink

View Thread: Selecting data from one SQLServer DB into another DB on same server
  • User profile image

    Dr Herbie wrote:
    I have a database server with two databases : a live database and a test database.  The test database is essentially an old version of the live database.

    The live database has been updated with some live data on some records.  Only one column has been updated.

    I want to copy the new data into the test database, only updating the single updated field in the relevant rows.

    I can't remember the syntax for this, nor can I find an answer on Google (I must be using the wrong term for this or something).

    Any help?


    EDIT: I'm hoping for something like:

    UPDATE [Test].Table set field = (select field from [Live].Table where [Live].Table.Field = [Test].Table.Field)

        [Test].dbo.[Table1].field = P.field
        [Production.dbo.[Table1] P
        [Test].dbo.[Table1].IDField = P.IDField  AND
        [Test].dbo.[Table1].field <> P.field