Wednesday, December 3, 2008

SQL server programming - Debug SQL Script

Debug SQL Script


Can someone please tell me if you can debug an sql script and if so where is
the debuging tool bar
If you can't - can you tell me how to print the value of a variable as it
goes through a loop

Jay
I use qyery analyzer to debug t-sql


> If you can't - can you tell me how to print the value of a variable as it
> goes through a loop


declare @i int
set @i=1
set nocount on
while @i<=10
begin
select @i
set @i=@i+1
end


"Jay" wrote in message


news:313BAF05-6202-4828-B31B-1FB86B111C76@microsoft.com...


- Hide quoted text -

> Can someone please tell me if you can debug an sql script and if so where
> is
> the debuging tool bar
> If you can't - can you tell me how to print the value of a variable as it
> goes through a loop


I have created the script in query analyzer and it is probably quite obviuos
to you where the debug tool bar is or how the step through the code - but I
just can't see it
Assume yyou have just created a script in query analyzer and you want to
step through it or insert breakpoints - take me through the process step by
step please

-----------------------------------------------Reply-----------------------------------------------
On Thu, 22 Mar 2007 07:10:06 -0700, Jay wrote:
>Can someone please tell me if you can debug an sql script and if so where is
>the debuging tool bar
>If you can't - can you tell me how to print the value of a variable as it
>goes through a loop


Hi Jay,

In SQL Server 2000, you could debug a stored procedure. Bring up the
object explorer from Query Analyzer (F8), find the stored procedure,
right-click and select "Debug".


In SQL Server 2005, you need Visual Studio to debug SQL Server code. But
even though I have Visual Studio installed, my attempts to debug SQL
Server 2005 procedures have thus far all failed. If you ever find out
how to do this, let me know! ;-)


--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

No comments: