SQL Copy Table

I sometimes need to just simply copy a small table to compare it against another run of the same program or some other legitimate reason to copy a table.

This SQL allows creating a new table and populating it with the data from an existing table.

SQL Sysobjects

This SQL is helpful when searching for specific strings within SQL code. I have used this code to search in databases too many times to mention. It is especially helpful when looking at a legacy database that I have never looked at before when trying to find things.

Visualize SQL XML Execution Plan using HTML

I’ve always used the Microsoft SQL Management Studio Execution plan feature to visualize the query plan. However today I was experimenting with the SQL XML showplan statement to see if I could learn anything more about execution plans by looking more closely at the code. As soon as I saw the XML it occurred to me that I could use XSLT to convert the output to HTML similar to the way that the SQL Management studio did it. I was curious to try, but before I writing my own, I checked to see if anyone else did it already and found this on github:

So, to demonstrate I created a simple SQL using temp tables so that I could perform some very basic tests.

Insert some sample data

Turn on the SHOWPLAN_XML in SQL and run query to produce the XML.

Then copy and paste the output XML data into a file and upload to the demo page that uses Justins HTML query plan visualizer library.

HTML XML Upload demo

SQL Convert Time to Decimal

Conversion from Time to Decimal