﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Stop large queries from running / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 07:35:05 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>[quote][b]sestell1 (3/19/2013)[/b][hr][quote][b]CapnHector (3/18/2013)[/b][hr]I always use a close parentheses ")" at the top of my code sheets (be careful if you add a go it may not work exactly, tend not to break any thing into batches except in roll out scripts.)  This generates a parse error and stops the batch from running.[/quote]Simple and effective, I like it![/quote]That or SELECT * FROM FakeTable will only stop single batch from executing if your script has multiple batches (separated by GO), only the one will be terminated by having such "parse" errors, other batches will not be affected. If you want to terminate your script for sure use high severity error:[code="sql"]RAISERROR ('Stop here',20,1) WITH LOG[/code]Nothing will pass the above;-)</description><pubDate>Tue, 19 Mar 2013 07:57:59 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>[quote][b]CapnHector (3/18/2013)[/b][hr]I always use a close parentheses ")" at the top of my code sheets (be careful if you add a go it may not work exactly, tend not to break any thing into batches except in roll out scripts.)  This generates a parse error and stops the batch from running.[/quote]Simple and effective, I like it!</description><pubDate>Tue, 19 Mar 2013 07:05:17 GMT</pubDate><dc:creator>sestell1</dc:creator></item><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>Thanks so much for all the help, I really appreciate your time. The select statement seems to be the most risk free ofcourse and works best for me. Cheers!</description><pubDate>Mon, 18 Mar 2013 21:53:59 GMT</pubDate><dc:creator>akberali67</dc:creator></item><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>[quote][b]sestell1 (3/18/2013)[/b][hr][quote][b]akberali67 (3/18/2013)[/b][hr]Hi,I have a query window with a lot of code but I do not want to run it entirely in error, is there something I can place in the beginning of the code that will throw me a message?Thanks,Akber.[/quote]The easiest thing to put at the top would be a simple select query referencing a table that does not exist. Something like [code="sql"]SELECT * FROM Table_That_Does_Not_Exist[/code].[/quote]I always use a close parentheses ")" at the top of my code sheets (be careful if you add a go it may not work exactly, tend not to break any thing into batches except in roll out scripts.)  This generates a parse error and stops the batch from running.</description><pubDate>Mon, 18 Mar 2013 14:21:50 GMT</pubDate><dc:creator>CapnHector</dc:creator></item><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>[quote][b]akberali67 (3/18/2013)[/b][hr]Hi,I have a query window with a lot of code but I do not want to run it entirely in error, is there something I can place in the beginning of the code that will throw me a message?Thanks,Akber.[/quote]The easiest thing to put at the top would be a simple select query referencing a table that does not exist. Something like [code="sql"]SELECT * FROM Table_That_Does_Not_Exist[/code].</description><pubDate>Mon, 18 Mar 2013 14:06:50 GMT</pubDate><dc:creator>sestell1</dc:creator></item><item><title>RE: Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>[quote][b]akberali67 (3/18/2013)[/b][hr]Hi,I have a query window with a lot of code but I do not want to run it entirely in error, is there something I can place in the beginning of the code that will throw me a message?Thanks,Akber.[/quote]To return a message to caller during T-SQL code execution you can use PRINT command.To throw an error use RAISERROR, together with using  BEGIN TRY .. CATCH, it will immediately re-direct code into error handling section.Problem with PRINT, is that the message is not guaranteed to be returned at the exact moment of execution of the command, as it has a low processing priority, you may find that messages are returned at the end of the whole code execution. RAISERROR causes immediate termination of the process when used with TRY ... CATCH. There is one more option:[code="sql"]RAISERROR ('Return message immidiately', 10,1) WITH NOWAIT;[/code]The above command raises error with such low severity which doesn't transferring control to the CATCH block making RAISERROR to behave exactly as PRINT (you can use formatting capability of RAISERROR there). WITH NOWAIT hint makes this command to execute with highest priority, so you will get message back as soon as execution hits this line.</description><pubDate>Mon, 18 Mar 2013 03:24:11 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>Stop large queries from running</title><link>http://www.sqlservercentral.com/Forums/Topic1432087-392-1.aspx</link><description>Hi,I have a query window with a lot of code but I do not want to run it entirely in error, is there something I can place in the beginning of the code that will throw me a message?Thanks,Akber.</description><pubDate>Mon, 18 Mar 2013 00:41:51 GMT</pubDate><dc:creator>akberali67</dc:creator></item></channel></rss>