Over time, I’ve had the need for more and more robust error handling in SQL. Initially I accomplished this with transactions, but eventually I needed something more. Finally, I came up with a template that I have started to use every time I start writing a new SQL file.
[viewcode] src=”http://facility9.com/wp-content/uploads/2008/01/sampleerrors.sql” showsyntax=”no” link=”yes” showsyntax=”no”[/viewcode]
Comments
You should make a template for yourself in SQL Server Management Studio: http://technet.microsoft.com/en-us/library/ms179334.aspx. That should save even more time.
If only I could figure out how to get something similar to this working in PostgreSQL I’d be all set.