0

Is this possible to debug the query in SQL Server 2005. I have heard about debugging support in SQL Server 2008. Also about debugging of stored procedures, but not about queries yet.

1 Answer 1

1

As far as I know, you have to have some kind of TSQL object in the database to debug to accomplish this. Since an ad hoc query doesn't directly correlate to a server object, there is nothing to point the debugger at. There also might be a small big of setup involved before you can actually start debugging those objects.

However, it if fairly easy to wrap sql statements into a procedure just for the sake of debugging if you have the proper rights. It would not be a good idea to do on a production server, but if you do not have stored procedure creation rights, you might still be able to create a global temporary stored procedure, solely for debugging purposes.

Examples:

--SQL to test
DECLARE @test DATETIME
SELECT @test = GetDate()
SELECT @test

--SQL wrapped in procedure just so it can be debugged CREATE PROCEDURE TestProcedure --(or ##testprocedure for global temp procedure) AS DECLARE @test DATETIME SELECT @test = GetDate() SELECT @test

Article illustrating some sql debugging info and examples in use - link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.