![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I am copying data from a remote server to a SQL server. When the rows are copied into the table I get an error because the unique value in the primary |
#2
| |||
| |||
|
|
You can use lookups for this but this will be slow if you have a large amount if records that need transferring. I personally would maintain a list of the rows and their state. I would do this through triggers so that if a row was inserted I would log this fact and if it was updated I would log this as well. I would then use the Data Driven Query task to execute the correct statement at the destination. -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "tammy" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:56D1C6D0-3BCB-4AA4-94B0-CC7DD8595B36 (AT) microsoft (DOT) com... I am copying data from a remote server to a SQL server. When the rows are copied into the table I get an error because the unique value in the primary key has been violated. What I would like to do is update the row if one already exists but insert a row if it doesn't. Any suggestions. |
#3
| |||
| |||
|
|
What would be nice is the MERGE command. Kinda like that other database (starts with a big O) has. It's a really usefull command, it lets you do an Insert / Update in one command. Or maybe will it be in Yukon ? Chris. "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message news:%23%23KcGMFrDHA.2520 (AT) TK2MSFTNGP09 (DOT) phx.gbl... You can use lookups for this but this will be slow if you have a large amount if records that need transferring. I personally would maintain a list of the rows and their state. I would do this through triggers so that if a row was inserted I would log this fact and if it was updated I would log this as well. I would then use the Data Driven Query task to execute the correct statement at the destination. -- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "tammy" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:56D1C6D0-3BCB-4AA4-94B0-CC7DD8595B36 (AT) microsoft (DOT) com... I am copying data from a remote server to a SQL server. When the rows are copied into the table I get an error because the unique value in the primary key has been violated. What I would like to do is update the row if one already exists but insert a row if it doesn't. Any suggestions. |
![]() |
| Thread Tools | |
| Display Modes | |
| |