473,768 Members | 8,596 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 9654

"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
2886
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
1790
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 output would be something like <p><span>text</span></p> (which is valid XHTML). Thank you very much...
1
1855
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 by the w3 stylebot. Currently, I've got all this free time and thought it would be great to try...
7
7292
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
1929
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 construction "(fprintf(stderr, "Can't open file.\n"), exit(0), 1))". ---- CODE ----
3
14538
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
4248
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
2450
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 than the first. In other words, I want to check that the range is valid. I notice that while...
2
2192
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 it is well formed and also conforms to the constraints defined by its DTD or schema. Therefore,...
10
4270
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 called fname I want to go through each character in
0
9576
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10017
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9961
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8840
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7384
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
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
2
3534
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.