Page 1 of 1

MS SQL Server Script cannot handle GOTO statements

Posted: Tue Aug 21, 2007 7:03 am
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

Posted: Tue Aug 21, 2007 8:03 pm
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

Posted: Mon Sep 10, 2007 8:10 am
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

Posted: Mon Sep 10, 2007 2:32 pm
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.

Posted: Tue Sep 11, 2007 1:52 am
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.