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 |
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-09 : 17:50:27
|
| If I am running through a loop and everytime it goes through the loop I want to test to see if that record exists or not, how do I do that? And if it exists, how do I skip that one and go to the next record? This is what I have right now:INSERT INTO tblHUDdata (CaseNumber,HoldingMor,ServingMor,EndorseYear,EndorseMonth,EndorseDay) Values ('" & HUDCaseNumber & "','" & HUDHoldMor & "','" & HUDServeMor & "','" & HUDEndorseYear & "','" & HUDEndorseMonth & "','" & HUDEndorseDay & "'"How do I check before I insert to see if that CaseNumber already is in the table? Thanks for your help!Brenda |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2004-08-09 : 17:53:05
|
| IF NOT EXISTS(SELECT * from tblHUDdata WHERE CaseNumber = '" & HUDCaseNumber & "')" & _"INSERT INTO tblHUDdata (CaseNumber,HoldingMor,ServingMor,EndorseYear,EndorseMonth,EndorseDay) Values ('" & HUDCaseNumber & "','" & HUDHoldMor & "','" & HUDServeMor & "','" & HUDEndorseYear & "','" & HUDEndorseMonth & "','" & HUDEndorseDay & "'"--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
|
|
|
|
|
|