I'm using SQL Server 2016 database project and my script is like below
DECLARE Marker NVARCHAR(50) = (SELECT Value FROM Table1 WHERE name = 'Marker')
IF( IS NOT NULL)
BEGIN
IF @Marker = 'Marker1' GOTO Marker2;
IF @Marker = 'Marker2' GOTO Marker3;
IF @Marker = 'Marker3' GOTO Marker4;
IF @Marker = 'Marker4' GOTO Marker5;
IF @Marker = 'Marker5' GOTO Marker6;
IF @Marker = 'Marker6' GOTO Marker7;
ELSE GOTO EmptyBlock;
END
MARKER1:
Code for marker 1
MARKER2:
Code for marker 2
MARKER3:
Code for marker 3
.
.
.
EmptyBlock:
PRINT 'No changes'
This script file will be executed after every deployment and based on deployment it will be skipping the previous lines and now it will be reached to marker 15.
It's taking too much time to execute even though there are few lines of code, I've finally found the issue due to GOTO statements. I don't know if using GOTO is best practice or not, if its not good practice using it in production site then please give me the suggestions for an alternate of GOTO.