Archive For The “SQL Server” Category

SQL Notifications: not very practical for large data sets

I ran into an interesting problem today with command-based SQL Notifications. We’ve recently introduced SysCache2 on a project as NHibernate’s level 2 cache provider, because of it’s ability to invalidate regions when underlying data changes, and I already wrote about some issues we had with it. Unfortunately we hit another road block today, this time [...]

Read more »

NHibernate.Caches.SysCache2: don’t forget to call SqlDependency.Start()

One of the projects I’m involved at work in is slowly migrating from classic ADO.NET to NHibernate. However, with around 2,200 stored procedures and 30 mapped classes, there is some overlap that cannot be avoided: a number of tables are written by one side but queried by the other. For performance, we want to use [...]

Read more »

Spotted in the wild…

This SQL Server function features: A name that doesn’t tell you anything ✔ Comments indicating non-existent functionality ✔ Big sections commented out with no explanation ✔ Using strings for date arithmetic ✔ After much thought I concluded that this code is functionally equivalent to DATEDIFF(MONTH, GETDATE(), @ReportDate), except you can choose a different year or [...]

Read more »

Deployment and source-control-friendly database versioning scripts

One of the projects I’m on has over 2,200 stored procedures. Until I arrived, none of these were under source control — the ‘stable’ version was whatever was on the production database server, and the ‘trunk’ version was whatever was in the development database server (which incidentally wasn’t even backed up). Anyway, I set about [...]

Read more »

Automatically log all INSERT, UPDATE and DELETE commands on a table in SQL Server

Just before Christmas we had a problem with an application database where rows were being mysteriously deleted. Unfortunately the table in question is written to by 20-30 stored procedures, so there was no single point in the application where I could put a trace. Instead, I wrote a quick generic script that would automatically create [...]

Read more »