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-11 : 12:32:08
|
| I need a statement that checks to see if a case doesn't exist, and if it doesn', I want to insert it into another table. This is what I have, but it doesn't work:IF NOT EXISTS(SELECT * from tblForeverHUDdata WHERE CaseNumber = '" & HUDCaseNumber & "') INSERT * INTO tblForeverHUDdata FROM tblHUDdataAny ideas? Thanks!Brenda |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-08-11 : 12:35:48
|
| [code]IF(NOT EXISTS(SELECT * from tblForeverHUDdata WHERE CaseNumber = '" & HUDCaseNumber & "'))BEGININSERT INSERT * INTO tblForeverHUDdata FROM tblHUDdataEND[/code]Dustin Michaels |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-11 : 12:43:32
|
| It doesn't like that. It says there is something wrong with *. What would it be?Brenda |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-11 : 12:54:12
|
| if the tblForeverHUDdata already exists in your db, you must use insert into tblForeverHUDdata(col1, ..., coln) select col1, ..., colnGo with the flow & have fun! Else fight the flow :) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-08-11 : 13:05:36
|
| Thanks! Works now!Brenda |
 |
|
|
|
|
|