Why Your WHERE Clause Ignores a Perfectly Good Index
You add an index on a column in the WHERE clause, run the query again, and still get a scan. Before adding another index, I look at how the ...
You add an index on a column in the WHERE clause, run the query again, and still get a scan. Before adding another index, I look at how the ...
I run scheduled jobs on several systems that remove data past its retention window. Depending on the system, that might mean anything older ...
Production data has a way of following an application into development and test. A database restore brings over the records needed to reprod...
The SQL Code Generation Tool is an open source project that I created to help automate the creation of stored procedures, model objects, a...
Here's an example of how to create a BAT file to backup a SQL Server database using SQLCMD and to zip the backup file using WinZip wz...
SQL Server can pull values out of an XML document and hand them back as ordinary rows and columns. The syntax depends on whether your data l...
If you ever need to work out, at runtime, what columns a stored procedure is going to return, SQL Server has a dynamic management function f...
"The SQL Server Database Engine automatically maintains indexes whenever insert, update, or delete operations are made to the underlyin...
"SQL Server and the .NET Framework are based on different type systems. For example, the .NET Framework Decimal structure has a max...
Email notifications stopped working for a SQL Server Agent job, and this was in the error log: [264] An attempt was made to send an email ...
This is the error I hit in SQL Server Management Studio when trying to expand the Databases node: Failed to retrieve data for this request...
If you change a table in the SQL Server Management Studio designer and try to save, you may get this: Saving changes is not permitted. The...
Before SQL Server 2008, if you needed to store a date you used DATETIME , whether or not you cared about the time. If you needed only a time...
SQL Server has a handy system stored procedure called sp_spaceused that reports the space used by a database or by an individual table. To ...
When programming in SQL you sometimes need to create a temporary table inside a stored procedure. That part is straightforward: SELECT Tra...
Building a genuine data access layer on top of LINQ to SQL raises a question that is harder than it looks: where do you draw the line betwee...
This one is one of the basics that all SQL programmers learn at some point, sometimes the hard way. @@IDENTITY returns the most recently c...
I do not have to do this often, but it comes in handy in certain situations. Setting a variable from dynamic SQL: DECLARE @MyValue INT ...
A simple function to calculate age from a date of birth. It handles the two cases that trip people up: a birthday later in the current year,...
This function is useful if you need to find the first day of the week for a given date. Because different clients and applications define th...