I think the answer is that SQL is a set-based language with several procedures attached. Because designers thought in terms of a set, they did not think that the usual type of debugging that exists in other languages is important. However, I think some of them are changing. You can set breakpoints in SQL Server 2008. I didn’t actually use it, since you must have SQL Server 2008 databases before it works, and most of our data is still SQL Server 2000. But it is available and it allows you to go through things. You will still have problems when your select statement is 150 lines long and it knows that the syntax is incorrect, but it cannot indicate exactly where, since this is all one command.
Personally, when I write a long procedural SP package, I create a test mode that includes showing me the results of the things that I do, the values of the key variables at certain points that interest me, and printing lines that let me know what steps were completed, and then collapse it all when done. This way, I can see what would happen if it worked for real, but did not damage any data in the database, if I am mistaken. I find this very useful. However, it can significantly increase the size of your program. I have a template that I use, which has most of the structure that I need to configure, so I don’t need to do too much time. Especially since I never add an insert. update or delete in proc without first checking the appropriate selection to make sure that I have the records that I want.
Hlgem
source share