Skip to content

Instantly share code, notes, and snippets.

@Hendy
Hendy / GetDatabaseRowCounts.sql
Last active July 24, 2018 19:45
MS SQL Get the row counts of all tables in current database
DECLARE @sql VARCHAR(255)
SET @sql = 'DBCC UPDATEUSAGE ("' + DB_NAME() + '")'
EXEC(@sql)
CREATE TABLE #Tables (tableName VARCHAR(255), tableRows INT)
INSERT #Tables
EXEC sp_msForEachTable
'SELECT PARSENAME(''?'', 1),
COUNT(*) FROM ?'
@Hendy
Hendy / PublishedContentTypeConverter.cs
Last active January 19, 2020 21:48
Ditto That Ditto
using Our.Umbraco.Ditto;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using Umbraco.Core.Models;
namespace Example.TypeConverters
@Hendy
Hendy / DeleteAllVersions.sql
Last active October 28, 2020 10:10
Umbraco - delete version history for all content
-- Create a temporary table for all documents which are published and not in the recycle bin
CREATE TABLE #Nodes (id int)
-- Delete all rows if the table exists before
TRUNCATE TABLE #Nodes
-- Insert all nodeIds from all documents which are published and not in the recycle bin
INSERT INTO #Nodes
SELECT N.id
FROM umbracoNode N
INNER JOIN cmsDocument D ON N.ID = D.NodeId
@Hendy
Hendy / FindDocTypes.sql
Last active August 29, 2015 14:15
Umbraco - find all docTypes using a given dataTypeId
DECLARE @dataTypeId AS INT
SET @dataTypeId = 0 -- DataTypeId to query on
SELECT DISTINCT(B.alias)
FROM cmsPropertyType A
INNER JOIN cmsContentType B ON A.contentTypeId = B.nodeId
WHERE A.dataTypeId = @dataTypeId
ORDER BY alias ASC
@Hendy
Hendy / TeaCommerceShipping.sql
Last active December 20, 2015 08:49
Tea Commerce Shipping Method Selector (using uComponents SQL DropDownList)
SELECT Name AS 'Text',
Alias AS 'Value'
FROM TeaCommerce_ShippingMethod
WHERE IsDeleted = 0
ORDER BY Sort