Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way to synchronize one field
Message
 
À
05/03/2012 14:12:37
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01537311
Message ID:
01537313
Vues:
47
This message has been marked as a message which has helped to the initial question of the thread.
>I have a field from a table in a database which I need to update from the same table in the same database but from another server. Both tables are the same. I just need to fix all the records with the same values as the other table as one SQL select I did emptied the related field.
>
>As this is from two different servers, do I need to do that in two steps or because the SSMS can see both servers there would be a way to synchronize that in one command?

If I understood you correctly now, you can create in your server a linked server to the one that has the correct data, then you can just use it in an update statement, something like
update yourDB.yourSchema.YourTable
set YourField = o.YourField from YourDB.YourSchema.YourTable m
join  [theOtherServer\theOtherInstance].YourDB.YourSchema.YourTable o on o.pk = m.pk
(Assuming the Schemas/Database also match, otherwise adjust as necessary.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform