dbTalk Databases Forums  

Re: update if it exists but insert if it doesn't

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Re: update if it exists but insert if it doesn't in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: update if it exists but insert if it doesn't - 11-16-2003 , 09:05 AM






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

Quote:
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.




Reply With Quote
  #2  
Old   
Christian Boult
 
Posts: n/a

Default Re: update if it exists but insert if it doesn't - 11-16-2003 , 10:19 PM






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

Quote:
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.





Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: update if it exists but insert if it doesn't - 11-17-2003 , 04:53 AM



And maybe it won't. In Yukon you do have MERGE JOIN tasks. You will still
have to do the logic AFAIK.

--

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


"Christian Boult" <chrboult (AT) sympatico (DOT) ca> wrote

Quote:
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.







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.