Posted By

RealRover on 08/07/10


Tagged

insert exists identity if not


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

roli000
ljayz
franksmile0310
Tyster


IF NOT EXISTS ... INSERT


 / Published in: SQL
 

  1. SET IDENTITY_INSERT dbo.UserGroup ON
  2.  
  3. IF NOT EXISTS (SELECT 1 FROM dbo.UserGroup WHERE UserGroupId = 21392)
  4. INSERT INTO dbo.UserGroup(UserGroupId, UserGroupTypeId, OwnerId, Name, Description, IsVisible)
  5. VALUES (21392, 1, 1, 'Anonymous Public Users', 'Anonymous Public Users', 0)
  6.  
  7. SET IDENTITY_INSERT dbo.UserGroup OFF

Report this snippet  

You need to login to post a comment.