Discussion:
if exists
(too old to reply)
mcnewsxp
2012-11-14 19:12:06 UTC
Permalink
so who do make sure the row you're about to insert doesn't already exist?

i tried:
If Not Exists(select * from tablename where code='1448523')
Begin
insert into tablename (code) values ('1448523')
End

and:

insert into tablename (code)
Select '1448523' Where not exists(select * from tablename where code='1448523')

neither worked for me
mcnewsxp
2012-11-14 19:33:52 UTC
Permalink
Post by mcnewsxp
so who do make sure the row you're about to insert doesn't already exist?
If Not Exists(select * from tablename where code='1448523')
Begin
insert into tablename (code) values ('1448523')
End
insert into tablename (code)
Select '1448523' Where not exists(select * from tablename where code='1448523')
neither worked for me
god i'm having an idiot day.
both work fine. i copied and pasted code in my project and didn't change the stored proc name.
i quit for the day.

Loading...