@@ -1227,39 +1227,6 @@ BEGIN
12271227 );
12281228END ;
12291229
1230- /*
1231- If we're writing to a table, we don't want to do anything else
1232- Or anything else after this, really
1233- We want the session to get set up
1234- */
1235- IF @debug = 1 BEGIN RAISERROR (N ' Do we skip to the GOTO and log tables?' , 0 , 1 ) WITH NOWAIT ; END ;
1236- IF
1237- (
1238- @output_database_name <> N ' '
1239- AND @output_schema_name <> N ' '
1240- AND @cleanup = 0
1241- )
1242- BEGIN
1243- IF @debug = 1 BEGIN RAISERROR (N ' Skipping all the other stuff and going to data logging' , 0 , 1 ) WITH NOWAIT ; END ;
1244- GOTO output_results;
1245- RETURN ;
1246- END ;
1247-
1248-
1249- /* just finishing up the second coat now */
1250- IF @debug = 1 BEGIN RAISERROR (N ' Do we skip to the GOTO and cleanup?' , 0 , 1 ) WITH NOWAIT ; END ;
1251- IF
1252- (
1253- @output_database_name <> N ' '
1254- AND @output_schema_name <> N ' '
1255- AND @cleanup = 1
1256- )
1257- BEGIN
1258- IF @debug = 1 BEGIN RAISERROR (N ' Skipping all the other stuff and going to cleanup' , 0 , 1 ) WITH NOWAIT ; END ;
1259- GOTO cleanup;
1260- RETURN ;
1261- END ;
1262-
12631230
12641231/* Start setting up individual filters */
12651232IF @debug = 1 BEGIN RAISERROR (N ' Setting up individual filters' , 0 , 1 ) WITH NOWAIT ; END ;
@@ -1705,8 +1672,10 @@ EXECUTE (@session_sql);
17051672IF @debug = 1 BEGIN RAISERROR (@start_sql, 0 , 1 ) WITH NOWAIT ; END ;
17061673EXECUTE (@start_sql);
17071674
1708- /* bail out here if we want to keep the session */
1709- IF @keep_alive = 1
1675+ /* bail out here if we want to keep the session and not log to tables*/
1676+ IF @keep_alive = 1
1677+ AND @output_database_name = N ' '
1678+ AND @output_schema_name IN (N ' ' , N ' dbo' )
17101679BEGIN
17111680 IF @debug = 1
17121681 BEGIN
@@ -1718,6 +1687,38 @@ BEGIN
17181687 RETURN ;
17191688END ;
17201689
1690+ /*
1691+ If we're writing to a table, we don't want to do anything else
1692+ Or anything else after this, really
1693+ We want the session to get set up
1694+ */
1695+ IF @debug = 1 BEGIN RAISERROR (N ' Do we skip to the GOTO and log tables?' , 0 , 1 ) WITH NOWAIT ; END ;
1696+ IF
1697+ (
1698+ @output_database_name <> N ' '
1699+ AND @output_schema_name <> N ' '
1700+ AND @cleanup = 0
1701+ )
1702+ BEGIN
1703+ IF @debug = 1 BEGIN RAISERROR (N ' Skipping all the other stuff and going to data logging' , 0 , 1 ) WITH NOWAIT ; END ;
1704+ GOTO output_results;
1705+ RETURN ;
1706+ END ;
1707+
1708+
1709+ /* just finishing up the second coat now */
1710+ IF @debug = 1 BEGIN RAISERROR (N ' Do we skip to the GOTO and cleanup?' , 0 , 1 ) WITH NOWAIT ; END ;
1711+ IF
1712+ (
1713+ @output_database_name <> N ' '
1714+ AND @output_schema_name <> N ' '
1715+ AND @cleanup = 1
1716+ )
1717+ BEGIN
1718+ IF @debug = 1 BEGIN RAISERROR (N ' Skipping all the other stuff and going to cleanup' , 0 , 1 ) WITH NOWAIT ; END ;
1719+ GOTO cleanup;
1720+ RETURN ;
1721+ END ;
17211722
17221723/* NOW WE WAIT, MR. BOND */
17231724WAITFOR DELAY @waitfor;
0 commit comments