Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Louis Nardozi,
This clr stored procedure will pivot any temp table by date.
The temp table must contain 1 to n NVarchar,Varchar or char columns, which the output will be grouped by.
The temp table must contain 1 to N numeric (not amy type char or any type of date) columns.
The temp table must contain exactly one column of date type. Probably any date type would work but I've only tested it with datetime.
Just include the .cs file in your existing clr library and deploy.
I haven't included a project because I figure most people will just include it in their library.
exec PivotByDate '#temp'
Note the quotes around the table name.
Why not include every table field in the included columns list for every index?
This article from Josef Richberg details the benefits of included columns for use in creating a cove...
Save time when copying data from SSMS to Excel by configuring the options to Include Column Headers....
How to include extra columns from the same table in a recordset based on the grouping.
Included columns enable nonclustered indexes to become covering indexes for a variety of queries, im...