Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rob41
Yak Posting Veteran
67 Posts |
Posted - 2010-09-30 : 12:06:43
|
| I getting violation of primary key constraint because i'm trying to merge two tables that have the same records. Table 1 has old records only. Table 2 has old and new records. I only want to get new records from merge while keeping old records which are locked. I tried adding a where statement at the end where Table 1 [Id] <> Table 2 [Id] this gives me the message The multi-part identifier "Table 1. Id" could not be bound. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-30 : 12:08:56
|
it should beINSERT INTO Table1SELECT columnsFROM Table2 tWHERE NOT EXISTS (SELECT 1 FROM Table1 WHERE PK=t.PK) PK is primray key of the tables------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
rob41
Yak Posting Veteran
67 Posts |
Posted - 2010-10-01 : 15:54:27
|
| that worked thanks :) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-02 : 02:48:40
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|