Skip to content

Instantly share code, notes, and snippets.

@phaniav
phaniav / GetTableSizes.sql
Created March 12, 2020 20:22
Get the sizes of all tables in SQL Server database
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
select princ.name
, princ.type_desc
, perm.permission_name
, perm.state_desc
, perm.class_desc
, object_name(perm.major_id)
from sys.database_principals princ
left join
sys.database_permissions perm
on perm.grantee_principal_id = princ.principal_id
@phaniav
phaniav / Create Anti-Package.ps1
Created April 5, 2020 23:00 — forked from michaellwest/Create Anti-Package.ps1
Generates an anti-package from the selected package. Requires SPE 3.1.
$response = Show-ModalDialog -HandleParameters @{
"h"="Create an Anti-Package";
"t" = "Select a package that needs an anti-package";
"ic"="People/16x16/box.png";
"ok"="Pick";
"ask"="";
"path"= "packPath:$SitecorePackageFolder";
"mask"="*.zip";
} -Control "Installer.Browse"
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:env="http://www.sitecore.net/xmlconfig/env/">
<!--
Author: https://twitter.com/epetrashen
Details: https://sitecorepc.wordpress.com/2020/08/12/supercharge-your-local-sitecore-instance-with-these-tips/
-->
<sitecore env:require="Local">
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
</hook>
$item = Get-Item master:/content/home
$newTemplate = [Sitecore.Configuration.Factory]::GetDatabase("master").Templates["Sample/Sample Item"];
$item.ChangeTemplate($newTemplate)