Reputation: 15953
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.
Upvotes: 0
Views: 485
Reputation: 136
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.
Upvotes: 1