Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Query Analyser Template

Author  Topic 

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2001-12-11 : 18:04:54
I though I might share with SQLTeam my default Template for Debugging/testing work on SQL Server..

Instructions:

Save this text as "Something.tsql" (I call it Debug.tsl) and place in your "SQL Query Analyser Template " Directory.. (By Default "C:\Program Files\Microsoft SQL Server\80\Tools\Templates\SQL Query Analyzer")

To load.. simply click the drop down on the "New" Icon and Select "Template.." Choose the Template.

To change the Debug parameters press CTRL+SHIFT+M.

I couldn't find a way to attach a file so it is in-line....

Enjoy!!

--Start of File
/*
Usefull SP's

EXEC SP_STORED_PROCEDURES
EXEC SP_TABLES
EXEC SP_HELPTEXT ' '
USE
DBCC CHECKDB
DBCC DBREINDEX (' ','',0)
DBCC SHOWCONTING ( )
DBCC SHOWCONTIG WITH TABLERESULTS, ALL_INDEXES --SQL2K ONLY
*/

--Flags for DB Commitment, Stats and Execution Plan
DECLARE @bTransactions bit
DECLARE @bStatistics bit
DECLARE @bShowPlan bit

--Set transaction, stats and show plan on/off
SET @bTransactions = <Transactions, bit, 0> -- 0 = Commit to DB, 1 = RollBack Transactions
SET @bStatistics = <Statistics, bit, 0> -- 0 = Don't show stats, 1 = Show Stats
SET @bShowPlan = <SHOW PLAN, bit, 0> -- 0 = Don't Show Plan, 1 = Show Plan without executing

if @bTransactions = 1
BEGIN
SET IMPLICIT_TRANSACTIONS ON
BEGIN TRAN
END

if @bStatistics = 1
BEGIN
SET STATISTICS TIME ON
SET STATISTICS IO ON
END

if @bStatistics = 1
BEGIN
SET SHOWPLAN_ALL ON
END

--Enter Your SQL Below Here






--Resetting Options
if @bTransactions = 1
BEGIN
ROLLBACK TRAN
SET IMPLICIT_TRANSACTIONS OFF
END

if @bStatistics = 1
BEGIN
SET STATISTICS TIME OFF
SET STATISTICS IO OFF
END

if @bStatistics = 1
BEGIN
SET SHOWPLAN_ALL OFF
END

--End of File

DavidM

A database is a set of axioms, the response to a query is a theorem, the process of deriving the theorem from the axioms is a proof, a proof is made by manipulating symbols according to agreed mathematical rules.

Edited by - byrmol on 12/11/2001 18:06:13
   

- Advertisement -