Update Data To A Different Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lisa66
    New Member
    • Sep 2007
    • 1

    Update Data To A Different Database

    Hi -

    I am having a problem on MS SQL Server 2005. I have 2 databases: DB1 and DB2. I am writing a stored procedure in DB1 to update data in DB2. Looks like this:

    ......
    USE [DB1]
    (stored procedure located in DB1:)
    ......
    UPDATE DB2.dbo.Names.L astName = 'junk'
    WHERE DB2.dbo.Names.L astName is not null

    I am NOT getting any errors but the table is NOT getting updated in DB2? What am I doing wrong?
  • davef
    New Member
    • Sep 2007
    • 98

    #2
    Originally posted by Lisa66
    Hi -

    I am having a problem on MS SQL Server 2005. I have 2 databases: DB1 and DB2. I am writing a stored procedure in DB1 to update data in DB2. Looks like this:

    ......
    USE [DB1]
    (stored procedure located in DB1:)
    ......
    UPDATE DB2.dbo.Names.L astName = 'junk'
    WHERE DB2.dbo.Names.L astName is not null

    I am NOT getting any errors but the table is NOT getting updated in DB2? What am I doing wrong?
    First off, to be parsed, your query should look more like this:
    Code:
    UPDATE DB2.dbo.Names [B]SET[/B] DB2.dbo.Names.LastName = 'junk' 
    WHERE DB2.dbo.Names.LastName is not null
    Check if this runs OK.

    Comment

    Working...