473,544 Members | 1,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Valid T-SQL syntax?

DFS
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


Jul 20 '05 #1
2 9643

"DFS" <no****@nospam. com> wrote in message
news:10******** *****@corp.supe rnews.com...
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


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
Jul 20 '05 #2
DFS

"Simon Hayes" <sq*@hayes.ch > wrote in message
news:40******** **@news.bluewin .ch...

"DFS" <no****@nospam. com> wrote in message
news:10******** *****@corp.supe rnews.com...
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


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


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


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2864
by: Shyamal Prasad | last post by:
Hi, Is there anyway to write JSP files as valid HTML of any sort. What I want to know is if JSP files are some sort of valid XML with a DTD that will check contents. Perhaps JSP files are valid XHTML documents? Any pointers would be appreciated. Searching the web seems to be leading me nowhere quickly. Cheers!
1
1771
by: Anna | last post by:
Hi all. I have probably a rather stupid question. If there is an HTML document, XML-formed using JTidy, is there any tool to convert it to valid XHTML? I.e. so that all the tags and attribute values will be XHTML compliant. For example, if the original document has following snippet: <p><div>text</div></p> (which is not valid XHTML), the...
1
1839
by: Beau Hayes | last post by:
Greetings, Thanks again for the kind answers to my last question. I'll confess up front this post is part "vent"; I'm just plain frustrated. I have been out of the business for almost three years. Three years ago CSS support was such that I wouldn't sink any more time in it than the time it took to pick one of the 8 core styles served up...
7
7274
by: JR | last post by:
Hey all, I have read part seven of the FAQ and searched for an answer but can not seem to find one. I am trying to do the all too common verify the data type with CIN. The code from the FAQ looks like this: #include <iostream>
23
1888
by: James Aguilar | last post by:
Someone showed me something today that I didn't understand. This doesn't seem like it should be valid C++. Specifically, I don't understand how the commas are accepted after the function 'fprintf'. What effect do they have in those parenthesis? I understand how the or is useful and why never to do it, I'm really just asking about that...
3
14516
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save dialog. The strange thing is that sometimes the save dialogue
1
4218
by: Robert Morgan | last post by:
|I'm trying to run a query on a database using php and postgres functions ||<?php db_connect(); $stat = pg_exec($connstr,"SELECT WSID from tblWorkstation "); while ($row = pg_fetch_rows($stat)) { print("<option> $row</option>"); } ?>
1
2441
by: illegal.prime | last post by:
Hey all, I have an app, that could take two numbers of any type of numerical type int, long, double, float, uint, ulong, etc. I want to check that the numbers are part of a range that I consider "valid". For my circumstances, I don't consider float.PositiveInfinity valid, nor do I consider the two numbers valid if the second number is smaller...
2
2167
by: Arpan | last post by:
I came across the following statement at http://windowssdk.msdn.microsoft.com/en-us/library/hdf992b8.aspx: Although an XML document is considered to be well formed if it meets all the syntactical requirements defined by the World Wide Web Consortium (W3C) Extensible Markup Language (XML) 1.0 Recommendation, it is not considered valid unless...
10
4229
by: SpreadTooThin | last post by:
Hi I'm writing a python script that creates directories from user input. Sometimes the user inputs characters that aren't valid characters for a file or directory name. Here are the characters that I consider to be valid characters... valid = ':./,^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' if I have a string...
0
7429
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7368
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7777
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7384
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5916
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5301
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1844
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.