Question
SQL: does if/else work as a query or only in a SP?
I'd like to insert a record if it doesn't exist or UPDATE it
if it does. I'm
doing this through a query via my app:
IF EXISTS (SELECT siteID
FROM weSiteMenusXML
WHERE siteID = 1)
INSERT
INTO weSiteMenusXML(siteID)
VALUES (1) ELSE
UPDATE weSiteMenusXML
SET xml = 'boo'
WHERE siteID = 1
Enterprise manager seems to be fine with this syntax, but it doesn't
actually do anything. Is SQL if/else logic only applicable to stored
procedures or is there just something goofy with my syntax?
-Darrel
doing this through a query via my app:
IF EXISTS (SELECT siteID
FROM weSiteMenusXML
WHERE siteID = 1)
INSERT
INTO weSiteMenusXML(siteID)
VALUES (1) ELSE
UPDATE weSiteMenusXML
SET xml = 'boo'
WHERE siteID = 1
Enterprise manager seems to be fine with this syntax, but it doesn't
actually do anything. Is SQL if/else logic only applicable to stored
procedures or is there just something goofy with my syntax?
-Darrel
