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 |
|
chriztoph
Posting Yak Master
184 Posts |
Posted - 2009-06-07 : 23:38:46
|
| hi to everyone,how to code a stored proc that will reject a record in INSERT if it is already exist..example:insert into tablename(employeeID....)values('CRL001'.....)if exist employeeIDthenprint 'the enployeeID is exist' |
|
|
chriztoph
Posting Yak Master
184 Posts |
Posted - 2009-06-08 : 00:02:30
|
| ok!i answered my question..thanks for reading my post! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-08 : 00:07:50
|
[code]insert into tablename(employeeID....)select 'CRL001'.....where not exists (select * from tablename x where x.employeeID = 'CRL001')[/code]or[code]if not exists (select * from tablename x where x.employeeID = 'CRL001')begin insert into tablename(employeeID....)values('CRL001'.....)end[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|