Archive for April 2014

TSQL: Restore a database without a log (ldf) file

I had to restore a bunch of databases missing a log file today. This was only a test server but I wanted to get it running as quickly as possible. The script here is based on the advice in this blog post from sqlskills. Note that this is very dodgy and should only be used […]

TSQL: Accuracy of DATETIME

Here’s something I didn’t know about the DATETIME data type in SQL Server…. ?View Code TSQLSELECT CAST(’2014-04-10 00:00:00.000′ AS DATETIME) UNION ALL SELECT CAST(’2014-04-10 00:00:00.001′ AS DATETIME) UNION ALL SELECT CAST(’2014-04-10 00:00:00.002′ AS DATETIME) UNION ALL SELECT CAST(’2014-04-10 00:00:00.003′ AS DATETIME) UNION ALL SELECT CAST(’2014-04-10 00:00:00.004′ AS DATETIME) UNION ALL SELECT CAST(’2014-04-10 00:00:00.005′ AS DATETIME) […]