Executing native SQL using NHibernate named queries

I’ve been doing a lot of work with NHibernate lately, particularly with named queries. It took a while to get it just right, so I figured it would be helpful to others (and to myself in the future) to note some of the gotchas and how-to steps to get it just right.
What is a named [...]

Scripting the deletion of objects in a SQL database (second version)

A few weeks ago, I wrote a post about deleting all tables and constraints in a database. It’s time to take that one step further!
The following SQL code will delete all stored procedures, user-defined functions (UDFs), views, table constraints, and tables (in that order) from a given SQL database. As with the original, you can [...]

Remove anonymous users from ASP.Net Membership tables

If you use the ASP.Net membership tools, have <anonymousIdentification enabled=”true” /> specified in your Web.config, and get lots of anonymous visitors, it’s only a matter of time before your database grows. What’s filling it up is the countless user records for your anonymous users.
If you don’t need to track user and profile information for an [...]

Deleting all tables and constraints in a database

We all need to do it from time to time — erase a bunch of tables in a SQL database. Sure, you can do this through Enterprise Manager, one table at a time, or write a bunch of DROP TABLE statements, but when doing it this way, you also need to ensure all foreign key [...]

Bad Programming: How not to use try/catch blocks

I just stumbled across the following SQL 2005 code:
BEGIN TRY
UPDATE [tabProgramSite]
SET
[Name] = @ProgramSiteName
WHERE [ProgramSiteID] = @ProgramSiteId
END TRY
BEGIN CATCH
END CATCH
Nothing like catching an error… and doing nothing about it. I hope the user experience isn’t as robust.