Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Begin End behavior...strange

Author  Topic 

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2003-05-15 : 16:49:08
I have a sproc that is acting rather strange.

I have this sproc:

Create Procedure dbo.spDeleteTest
@PKID BIGINT
,@EditID BIGINT
,@ErrorMSG nvarchar(100) OUTPUT
AS

SET NOCOUNT ON

BEGIN TRANSACTION trTest

Declare @errmsg nvarchar(100)
Set @errmsg = ''
IF(@PKID = '' OR @PKID IS NULL)
BEGIN
Set @errmsg = 'No Record provided for Delete'
END
ELSE
BEGIN
-- ******************* TEST ****
IF EXISTS(Select 'True' From Test Where TestID = @PKID)
BEGIN
Delete FROM Test WHERE TestID = @PKID
if(@@error <> 0) Set @errmsg = 'Delete Failed'
END
ELSE
BEGIN
Set @errmsg = 'Record does not exist'
END
END

The error:Server: Msg 170, Level 15, State 1, Procedure spDeleteTest, Line 4
Line 4: Incorrect syntax near 'BEGIN'.

However, if I take out this line
-- ******************* TEST ****
the sproc is fine.

Why does the comment throw an error? I couldn't find anything outright
on the web. Any clues?

________________________________________________
Everytime I think I understand women, I leave the tavern and go home to be humbled.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-05-15 : 16:55:30
I just copied your code into Query Analyzer and successfully created the stored procedure. There is probably a hidden character in your code. Copy the code from this post and then paste into Query Analyzer. I'm not joking either. This has happened to many people. Let us know if that works or doesn't work. I'm curious. If it doesn't, then we'll need to know what version of SQL Server, service pack #?

Tara
Go to Top of Page

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2003-05-15 : 17:03:29
All Be Damned!

I did a chop and glue... Its fine.

WTF?

I spent an hour doing "What the f***?"

Thanks

________________________________________________
Everytime I think I understand women, I leave the tavern and go home to be humbled.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-05-15 : 17:07:49
I know it is so weird. I have come across it once before and have read a few posts here dealing with the same thing.

Tara
Go to Top of Page
   

- Advertisement -