Prev: Insert Data Generate Date into an SSRS Report Header
Next: Retrieve unique values based on multiple columns
From: Plamen Ratchev on 23 Jun 2010 18:35 This will not work because the key is the email column. Using EXCEPT can potentially insert rows with duplicate emails if any other column differs. MERGE would be a better option on SQL Server 2008, but here the requirement is SQL Server 2005. -- Plamen Ratchev http://www.SQLStudio.com
From: --CELKO-- on 24 Jun 2010 10:57 >> This will not work because the key is the email column. << We don't have any DDL, so I don't know what the key is. I have the horrible feeling it is the vague, generic "id" which might be an IDENTITY column (ugh)! >> Using EXCEPT can potentially insert rows with duplicate emails if any other column differs. << But then they are not duplicates :) >> MERGE would be a better option on SQL Server 2008, but here the requirement is SQL Server 2005. << Agreed.
From: Tony Rogerson on 24 Jun 2010 11:45 The poster stated EMAIL hence Plamen comment no doubt. --ROGGIE-- "--CELKO--" <jcelko212(a)earthlink.net> wrote in message news:a770c009-4e9b-42dd-99ea-ef1ee8b7a0fb(a)i31g2000yqm.googlegroups.com... >>> This will not work because the key is the email column. << > > We don't have any DDL, so I don't know what the key is. I have the > horrible feeling it is the vague, generic "id" which might be an > IDENTITY column (ugh)! > >>> Using EXCEPT can potentially insert rows with duplicate emails if any >>> other column differs. << > > But then they are not duplicates :) > >>> MERGE would be a better option on SQL Server 2008, but here the >>> requirement is SQL Server 2005. << > > Agreed.
From: Geniusinuse on 30 Jun 2010 00:51 Deberías investigar el UPSERT o MERGE, en el cual se utiliza una tabla temporal o derived table en la cual insertas los registros y efectúas un JOIN, lo que cruza es UPDATE, lo que es nuevo INSERT. Esto te ayuda? Saludos "jonjack via SQLMonster.com" <u61099(a)uwe> escribió en el mensaje de noticias:a9e73e845f9a6(a)uwe... > Hi > > Im a SQL Server newbie and am a bit confused by the number of different > methods I have seen posted on the web about approaching this problem. > > I am using SQL Server 2005 and I have about 500 records defined in simple > terms for brevity: > > > ID | EMAIL | NAME | etc > > I have generated INSERT statements for all the records via Management > Studio > | Tasks | Generate Scripts. > > Im migrating this data to anotaher db that already has records and there > are > some duplicates with my data. I need to do a check that the record does > not > exist and then do an INSERT if not (Im not doing any UPDATEs). The check > should be on the EMAIL field. > > Can anyone advise me on the 'simplest' approach? > Im not too familiar with transactions is that the way forward? > > > > regarda > Jon > > -- > Message posted via http://www.sqlmonster.com >
First
|
Prev
|
Pages: 1 2 Prev: Insert Data Generate Date into an SSRS Report Header Next: Retrieve unique values based on multiple columns |