I feel like I should know how to do this, but:
I have to write some sql to add an entry to a table. I want the sql to check first that the entry does not exist though and I cannot get this to work.
This is the sql I've been using, but it doesn't work - can anyone tell me what I've missed (I think it's probably the way I've done the if statement - I learned this from a book only this morning)?
SELECT ListName
FROM ListNames
WHERE (ListName = 'SampleListName');
IF @@rowcount = 0
INSERT
INTO ListNames(ListName)
VALUES ('SampleListName')
thanks
I have to write some sql to add an entry to a table. I want the sql to check first that the entry does not exist though and I cannot get this to work.
This is the sql I've been using, but it doesn't work - can anyone tell me what I've missed (I think it's probably the way I've done the if statement - I learned this from a book only this morning)?
SELECT ListName
FROM ListNames
WHERE (ListName = 'SampleListName');
IF @@rowcount = 0
INSERT
INTO ListNames(ListName)
VALUES ('SampleListName')
thanks