all groups > sql server (alternate) > january 2004 >
You're in the

sql server (alternate)

group:

Valid T-SQL syntax?


Valid T-SQL syntax? DFS
1/31/2004 11:23:40 PM
sql server (alternate):
Version 1:
--------------------------------
If Condition = A
UPDATE query 1
UPDATE query 2
ELSE IF Condition = B
UPDATE query



Version 2:
--------------------------------
If Condition = A
BEGIN
UPDATE query 1
UPDATE query 2
END
ELSE IF Condition = B
BEGIN
UPDATE query
END


Or are they functionally equivalent?

Thanks



Re: Valid T-SQL syntax? Simon Hayes
2/1/2004 7:43:06 AM

[quoted text, click to view]

See the Books Online entry for IF ... ELSE ... Version 1 is not valid
syntax - IF must be followed by a single SQL statement, or by a block of
statements enclosed in BEGIN ... END. Version 2, on the other hand, is
correct. Try it yourself in Query Analyzer, and you should get a syntax
error using version 1.

Simon

Re: Valid T-SQL syntax? DFS
2/1/2004 8:48:33 AM

[quoted text, click to view]

Thanks. Yes, I tried it last night and it's just as you say.



AddThis Social Bookmark Button