SQL: Conditional insert

1 post / 0 new
benzzon
benzzon's picture
SQL: Conditional insert
IF NOT EXISTS(SELECT * FROM dbo.tablename WHERE field1='value1')
 
BEGIN
 insert into tablename(field1,field2) values ('value1','value2')
END
 
GO