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
 General SQL Server Forums
 New to SQL Server Programming
 how to debug the Store Procedure in Sql Server

Author  Topic 

sharmasumit45
Starting Member

9 Posts

Posted - 2008-01-15 : 03:45:59
Hi every One,

I am new to Sql and I find it dificult to write complex Sp(Stored Procedures).Can you please help me in understanding the debugging of Sp.

Thanks In advance

sumit

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-15 : 04:36:04
One crude method of debugging is to give print statements after query batches and checking intermediate results.
Also go through this link to learn usage of query analyser in debugging:-

[url]http://articles.techrepublic.com.com/5100-9592_11-5768655.html[/url]
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-01-15 : 05:02:00
in ss 2k5 you can debug only in visual studio.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page

sharmasumit45
Starting Member

9 Posts

Posted - 2008-01-15 : 23:11:21
Thanks a lot guys you are wonderful.I am not expecting the answer so early.Actually I am new to programming and also to this forum.I hope in future also I will get the help from you guys
Thanks visakh16 and spirit1.

Regards
sumit
Go to Top of Page

sharmasumit45
Starting Member

9 Posts

Posted - 2008-01-17 : 08:06:59
Can you help me in one more thing When ever I see a complex Stored procedure I feel scared.But I can see people using print command use to debug it and also some are using sql profiler to trace the database updates/changes.I am scared how can they do this so effortlessely.Actally I don't know these two technique can you please help me with example script.

Regards
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-01-17 : 08:48:29
declare @id int
select @id = 3
select ... where someId = @id
print('@id=' + @cast(id as varchar(10)) -- this is for debug reasons..

--etc...

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -