Let's consider this basic insert
insert into TableName (Col1,Col2,Col3) values (Val1,Val2,Val3)
i want this insert to be done only if Val1 !=null and Val3!=null How to accomplish this?
Let's consider this basic insert
insert into TableName (Col1,Col2,Col3) values (Val1,Val2,Val3)
i want this insert to be done only if Val1 !=null and Val3!=null How to accomplish this?
Is this what you're looking for?
IF (Val1 is not null AND Val3 is not null)
BEGIN
insert into TableName (Col1,Col2,Col3) values (Val1,Val2,Val3)
END
On second thought BeachBlocker's answer is quite nice too. I've modified it a little:
insert into TableName (Col1,Col2,Col3) select Val1,Val2,Val3 where Val1 is not null and Val3 is not null
insert into TableName (Col1,Col2,Col3) select Val1,Val2,Val3 where Val1 is not null and Val3 is not null