473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Unexpected SQL syntax error!

Neo
I posted this to microsoft.public.sqlserver.programming, but no one
could answer my question. So I think it is a good place to re-post my
question here.

My question:

I found that if you do not include any effective SQL statement between
BEGIN/END block, SQL Server 2000 Query Analyzer will think it is an
error:

Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'end'.

if 1=1
select getdate()
else
begin
--select 'ok'
end

Is this behavior a SQL standard or simply a M$ standard glitch?
Jul 20 '05 #1
5 9109
On 31 Aug 2003 22:41:51 -0700 in comp.databases.ms-sqlserver,
ne***********@msn.com (Neo) wrote:
I posted this to microsoft.public.sqlserver.programming, but no one
could answer my question. So I think it is a good place to re-post my
question here.

My question:

I found that if you do not include any effective SQL statement between
BEGIN/END block, SQL Server 2000 Query Analyzer will think it is an
error:

Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'end'.

if 1=1
select getdate()
else
begin
--select 'ok'
end

Is this behavior a SQL standard or simply a M$ standard glitch?


From books online:
<--
Syntax
BEGIN
{ sql_statement | statement_block }
END

Arguments
{sql_statement | statement_block}
-->

Shows the argument is not optional. :-)

--
A)bort, R)etry, I)nfluence with large hammer.

(replace sithlord with trevor for email)
Jul 20 '05 #2
Neo
.......

Can anyone direct me to other newsgroups for this question?

ne***********@msn.com (Neo) wrote in message news:<96**************************@posting.google. com>...
I posted this to microsoft.public.sqlserver.programming, but no one
could answer my question. So I think it is a good place to re-post my
question here.

My question:

I found that if you do not include any effective SQL statement between
BEGIN/END block, SQL Server 2000 Query Analyzer will think it is an
error:

Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'end'.

if 1=1
select getdate()
else
begin
--select 'ok'
end

Is this behavior a SQL standard or simply a M$ standard glitch?

Jul 20 '05 #3
Was my answer not helpful?

SK

Neo wrote:
......

Can anyone direct me to other newsgroups for this question?

ne***********@msn.com (Neo) wrote in message news:<96**************************@posting.google. com>...
I posted this to microsoft.public.sqlserver.programming, but no one
could answer my question. So I think it is a good place to re-post my
question here.

My question:

I found that if you do not include any effective SQL statement between
BEGIN/END block, SQL Server 2000 Query Analyzer will think it is an
error:

Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'end'.

if 1=1
select getdate()
else
begin
--select 'ok'
end

Is this behavior a SQL standard or simply a M$ standard glitch?


Jul 20 '05 #4

"Neo" <ne***********@msn.com> wrote in message
news:96**************************@posting.google.c om...
Is this behavior a SQL standard or simply a M$ standard glitch?


Having this message is not a bad thing as it tends to indicate that your
code is incorrect, rather than the opposite.

John
Jul 20 '05 #5
On Tue, 02 Sep 2003 11:36:27 GMT in comp.databases.ms-sqlserver, Steve
Kass <sk***@drew.edu> wrote:
Was my answer not helpful? Neo wrote:
......

Can anyone direct me to other newsgroups for this question?


or mine?

consider changing:

if @foo=1
set @bar = 2
else
set @bar = 3

to:
if @foo=1
set @bar = 2
else
-- set @bar = 3

you'd get the same sort of error, unless of course some more code
followed that bit in which case you'd just get unexpected results.

--
A)bort, R)etry, I)nfluence with large hammer.

(replace sithlord with trevor for email)
Jul 20 '05 #6

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

Similar topics

5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
8
by: Jim Michaels | last post by:
C:\prj\quiz\withusers>php tareports.php PHP Parse error: syntax error, unexpected T_ELSE in C:\prj\quiz\withusers\tareports.php on line 205 this is the section of code. if (isset($row4)) {...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
4
kestrel
by: kestrel | last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on. Heres what i have <?php...
1
by: basswhizz | last post by:
Hi guys im having trouble with somethings else now can you help out thanks!! Im getting this error message Parse error: syntax error, unexpected $end Here's my code cheers!!] <?php //...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
20
by: Jim Michaels | last post by:
I have a 638 line glob of PHP code & HTML that won't run. I get "PHP Parse error: syntax error, unexpected '}' in quiz\\quiz.php on line 594". I wrote a brace checker that checks perens, square...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
3
paulrajj
by: paulrajj | last post by:
hi to all, i am getting syntax error on my code.. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62 ...
10
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...

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.