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 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2009-08-27 : 15:14:55
|
This is not quite working the way it should: UPDATE ImportNumbers SET StatusMsg = 'Duplicate Numbers Found' WHERE InvoiceNum IN ( SELECT InvoiceNum FROM ImportNumbers GROUP BY InvoiceNum HAVING Count(*) > 1 ) AND LocationID = @LocationID If there is another InvoiceNum in the table but a different LocationID, it updates and it shouldn't.Suggestions?Thanks,Zath |
|
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2009-08-27 : 15:25:11
|
Ok, got it working.Should have had an additional WHERESELECT invoicenum FROM ImportNumbersWHERE LocationID = @LocationIDGROUP BY invoicenum HAVING COUNT(*) > 1 |
 |
|
|
|
|
|