Category: Tips

Tip: Use System Views to Compare Column Datatypes

Let’s say that you have a staging table, that then loads to a destination table in the same database.  If you have more than one person working on the process, data types can quickly get out of whack. So: what’s the easiest way to compare datatypes bewteen two “matching” tables? System views, my friends! Let’s create […]

Tip: RESTORE FILELISTONLY / WITH MOVE

As we’ve seen in recent DBARant-able tales, not everyone is completely familiar with methods of restoring SQL backup files to new filepaths. The answer, in short, is: RESTORE FILELISTONLY/ RESTORE WITH MOVE. Let’s say that you backed up the database ImportantDB from your production server, and you want to restore it to a test server. […]

N Things Worth Knowing About CTEs

Edit: This post was originally published on August 26, 2010. If you haven’t messed with them yet, you should know that CTEs (Common Table Expressions) – new in SQL Server 2005 – are actualy pretty #awesomesauce. A CTE is, in essence, a temporary view attached to your SELECT statement.  They’re good for a number of uses, […]