Monthly Archives: June 2016

T-SQL: Script all Synonyms for a Database

If you have synonyms in a database that point to a database that you need to move or rename, you will need to update those synonyms as part of your update. Here’s a script that generates DROP/CREATE statements for all … Continue reading

Posted in T-SQL | Leave a comment

T-SQL: Delete Rows in a Batch Loop

Here’s a simple pattern to perform an action in a batch loop with T-SQL. DECLARE @RowCount INT = 1; — Initialize to a value >0 to begin the loop   SET ROWCOUNT 20000; — The number of rows to delete … Continue reading

Posted in MS SQL Server, T-SQL | Leave a comment

T-SQL: Describe a temp table with sp_help

If you are looking to verify the structure of a temp table you have created within a SQL query batch, you can use sp_help to describe the table. SELECT Top 1 * INTO #MyTempTable FROM dbo.SomeTable   EXEC tempdb.dbo.sp_help N’#MyTempTable’ … Continue reading

Posted in MS SQL Server, T-SQL | Leave a comment

T-SQL: Try/Catch Pattern

Here’s a simple try/catch pattern for a SQL Server query to help roll back a transaction when something goes awry: BEGIN Tran;   BEGIN Try — do stuff END Try BEGIN Catch IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION; Throw END … Continue reading

Posted in MS SQL Server, T-SQL | Leave a comment

T-SQL: Convert from UTC Date to Local Date

Here’s a quick T-SQL expression to convert from a UTC Date to Local Date: DATEADD(HH, DATEDIFF(HH, GETUTCDATE(), GETDATE()), MyUtcDate) AS MyLocalDate An even better idea would be to avoid the conversion by using the datetimeoffset sql column type.

Posted in T-SQL | Leave a comment

Ready-to-Go Test-beds: Download Virtual Machines for Windows, Linux, and MacOS

If you are looking for a quick test-bed to try out browser compatibility, or just want a fast and easy machine to try something out without dirtying up your own machine, check out these ready-to-go virtual machines for download from … Continue reading

Posted in Internet Explorer, Microsoft Edge, Virtualization | Leave a comment