Posts

A Way to Handle Raised Errors in Both Dynamic and Static SQL Code

If you've needed a reliable way to handle errors that might be raised in both dynamic and static SQL code, here is what I've been doing: SET   ANSI_NULLS   ON GO SET   QUOTED_IDENTIFIER   ON GO -- ============================================= -- Author:      Erland Sommarskog - http://www.sommarskog.se/error_handling_2005.html -- Create date: 2009/11/29 -- Description: **Call this sp from within your --              CATCH block** This --              reraises/throws the most recent --              error. Please see --              http://w...

HOWTO: Quickly and Efficiently Get An IEnumerable of Directories and Files

Have you ever wanted to get an IEnumerable of files and directories and had to either make do with or convert from an Array because the System.IO namespace didn't provide methods of doing this? In .NET 4 you can do this quickly and efficiently. Check out the MSDN documentation here .

HOWTO: Find out the Sizes of All the User Tables in a Database in SQL

Do you need to know the sizes for all the user tables in your database? I found this script by Mitchel Sellers, an SQL Server MVP ,  to be very handy. I've modified it slightly, but you can get the original on his blog . Thank you Mitchel for allowing me to post this here. Please excuse the poor formatting, I am working on finding and implementing a decent code formatted for both SQL and C#. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author:            Mitchel Sellers - mitchel.sellers@gmail.com -- Create date: 2007/06/27 -- Description: Obtains spaced used data for --                            ALL user tables in the database. --            ...

HOWTO: Generate a Random String of Characters in SQL

Here's a stored procedure to generate a string of random characters. This is useful when, for example, one needs to generate a random password. Please excuse the poor formatting, I am working on finding and implementing a decent code formatted for both SQL and C#. Thanks to  Raymond Lewallen  over at CodeBetter.com SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author:            Raymond Lewallen --                    http://codebetter.com/blogs/raymond.lewallen/archive/2005/05/17/63281.aspx -- Create date: 2005/05/16 -- Description: Generate a random string of --                            given length. --...