MS SQL Server Script cannot handle GOTO statements

Got a problem you cannot solve? Try here.
Post Reply
chris.mouton
Posts: 3
Joined: Fri Aug 17, 2007 7:55 am
Contact:

MS SQL Server Script cannot handle GOTO statements

Post by chris.mouton »

Hi,

After investigating why my script keeps on failing when running through IA setup and not through SQL Server Management Studio I found that my scripts are brokern up at each GO statement. However, since some of my stored procedures contain GOTO statements, it seem to be broken up on these lines as well. Since the half extracted command (between the last GO statement and the GOTO statement) is not valid, it fails the installation. I very strongly assume that IA is breaking my script up in chunks

Has anybody encounter this and have a solution or work-around?

Thanks
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Post by Gizm0 »

Yes, its true. Scripts are parsed using GO statements and are executed in chunks to avoid overload.

I can't think of a workaround or solution except from running the script using the osql tool, like
osql -E -S (local)\\INSTANCE -i drive://my/path/here/script.sql
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
takayari
Posts: 2
Joined: Mon Sep 10, 2007 7:32 am

Post by takayari »

The problem is that a GOTO is the first word on the row, so in every stored procedures that uses a GOTO statement I insert an if statement with a true condition before every GOTO:

if (1=1) goto MyLabel
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Post by Gizm0 »

takayari wrote:The problem is that a GOTO is the first word on the row, so in every stored procedures that uses a GOTO statement I insert an if statement with a true condition before every GOTO:

if (1=1) goto MyLabel
NO, this is NOT a nice away. You add some serious overhead at the SQL Server's execution plan by adding a condition that does nothing. You only manage to confuse SQL Server executiong engine some more.
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
takayari
Posts: 2
Joined: Mon Sep 10, 2007 7:32 am

Post by takayari »

I know it isn't a good solution but in my case it's the only way I can do.
This is a temporary solution because I hope that the IA developers will solve this problem as soon as possible.
Post Reply