I have the following code...
IF
EXISTS (SELECT Address.AD_ID FROM Address WHERE Addr_ID = '319' AND AD_ID = '1')
THEN
UPDATE Address SET Street = 'Street1',City = 'City1',ST = 'ST1',ZIP = 'ZIP1',Phone = 'Phone1'
WHERE Addr_ID = '319' and Ad_ID = '1';
ELSE
INSERT INTO Address(Addr_ID,Street,City,ST,ZIP,Phone,Ad_ID)
VALUES('319','Street1','City1','ST1','ZIP1','Phone1','1');
END IF
and am getting...
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'THEN'.
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'ELSE'.
Server: Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'END'.
returned in query analyzer. I have played with the structure and still get the same results. What am I missing?
And if someone responds is there a way to validate whether an update was successful in ASP like...
var = conn.execute(sql)
if var = -1 then
NG
else
Good
end if
or to return a variable from SQL
thanks for either or...
IF
EXISTS (SELECT Address.AD_ID FROM Address WHERE Addr_ID = '319' AND AD_ID = '1')
THEN
UPDATE Address SET Street = 'Street1',City = 'City1',ST = 'ST1',ZIP = 'ZIP1',Phone = 'Phone1'
WHERE Addr_ID = '319' and Ad_ID = '1';
ELSE
INSERT INTO Address(Addr_ID,Street,City,ST,ZIP,Phone,Ad_ID)
VALUES('319','Street1','City1','ST1','ZIP1','Phone1','1');
END IF
and am getting...
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'THEN'.
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'ELSE'.
Server: Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'END'.
returned in query analyzer. I have played with the structure and still get the same results. What am I missing?
And if someone responds is there a way to validate whether an update was successful in ASP like...
var = conn.execute(sql)
if var = -1 then
NG
else
Good
end if
or to return a variable from SQL
thanks for either or...