Skip to content

Instantly share code, notes, and snippets.

View timgaunt's full-sized avatar

Tim Gaunt timgaunt

View GitHub Profile
@timgaunt
timgaunt / gist:5787287
Created June 15, 2013 07:40
Size of all tables in SQL Server
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
(SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB,
(SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB,
((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
@timgaunt
timgaunt / Content.sql
Created July 27, 2015 18:46
Export Umbraco data in pivot/crosstab table
DECLARE @cols NVARCHAR(max), @ContentTypeId int
SET @ContentTypeId = 1074
SELECT @cols = STUFF((
SELECT DISTINCT TOP 100 PERCENT
'],['
+ CONVERT(varchar, Name + ' (' + CONVERT(varchar, id) + ')', 255)
FROM
dbo.cmsPropertyType
WHERE