Saturday, February 25, 2012

Accidentailly changed too many records -

Hi
This might be a trivial question, bit I'm not that experienced in updating
from a table in another database.
We changed a number of records in a table, and unfortunately we did a
mistake so too many was changed.
I've now restored a backup from last night and wants to update the database
with the data from the table in the backup.
The backup has been restored as a new database on the same server as the
"live" database.
I'm trying to do it with an UPDATE statement where I update the tesxt in one
field with the text from the backup, where the record Id is the same in both
tables. My problem is then, that apparently I can't fiugre out to define
that I want to use data from a different database.
The code I'm trying to run is :
UPDATE findimension
SET beskrivelse = Test629.dbo.findimension.beskrivelse
FROM Test629.dbo.findimension.beskrivelse, beskrivelse
WHERE finfimension.findimensionID =
Test629.dbo.findimension.findimensionID
I'm working on the database I want to update, and I want to update from the
database name 'Test629'. When I run the above statement, it tells me that it
can't find server Test629 in sysservers - which is fair enough, since it
isn't a server but a database...:-).
How do I define this in the right way, so it looks at the "Beskrivelse"
column in the findimension table in the Test629 database.
Hope some of you can help?
Regards
Steen
You referenced the table as Test629.dbo.findimension.beskrivelse - since
there are four parts to the name, the engine assumes that Test629 is a
server name. The last part of the name appears to be a column name - remove
it.
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...
> Hi
> This might be a trivial question, bit I'm not that experienced in updating
> from a table in another database.
> We changed a number of records in a table, and unfortunately we did a
> mistake so too many was changed.
> I've now restored a backup from last night and wants to update the
database
> with the data from the table in the backup.
> The backup has been restored as a new database on the same server as the
> "live" database.
> I'm trying to do it with an UPDATE statement where I update the tesxt in
one
> field with the text from the backup, where the record Id is the same in
both
> tables. My problem is then, that apparently I can't fiugre out to define
> that I want to use data from a different database.
> The code I'm trying to run is :
> UPDATE findimension
> SET beskrivelse = Test629.dbo.findimension.beskrivelse
> FROM Test629.dbo.findimension.beskrivelse, beskrivelse
> WHERE finfimension.findimensionID =
> Test629.dbo.findimension.findimensionID
> I'm working on the database I want to update, and I want to update from
the
> database name 'Test629'. When I run the above statement, it tells me that
it
> can't find server Test629 in sysservers - which is fair enough, since it
> isn't a server but a database...:-).
> How do I define this in the right way, so it looks at the "Beskrivelse"
> column in the findimension table in the Test629 database.
> Hope some of you can help?
> Regards
> Steen
>
|||Thanks...that was it...
Regards
Steen
Scott Morris wrote:[vbcol=seagreen]
> You referenced the table as Test629.dbo.findimension.beskrivelse -
> since there are four parts to the name, the engine assumes that
> Test629 is a server name. The last part of the name appears to be a
> column name - remove it.
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...

No comments:

Post a Comment