Skip to content

Instantly share code, notes, and snippets.

@zommarin
zommarin / gist:1236810
Created September 23, 2011 05:34 — forked from shbaz/gist:1188006
Size of tables in a SQL Server database
--
-- Count rows in all tables, display tables with rows
--
CREATE TABLE #T (
name NVARCHAR(255),
[rows] INT,
reserved NVARCHAR(255),
data NVARCHAR(255),
index_size NVARCHAR(255),
@zommarin
zommarin / gist:1236809
Created September 23, 2011 05:34 — forked from shbaz/gist:1188016
Find non-dbo tables, views and procedures [SQL Server]
--
-- Select the tables, views and stored procedures that are not in the [dbo] schema
--
-- Useful when double checking that prople has not run scripts with the wrong user
-- for databases that have everything in the [dbo] schema.
--
SELECT 'Table' AS [Type] ,
'[' + s.name + '].[' + t.name + ']' AS [Name]
FROM sys.tables AS t
@zommarin
zommarin / gist:1236808
Created September 23, 2011 05:34 — forked from shbaz/gist:1188035
Remove all non-dbo schemas, views and stored procedures
--
-- Remove non dbo tables, views and stored procedures
--
BEGIN TRANSACTION
DECLARE @Cmd NVARCHAR(max);
DECLARE [CmdCursor] CURSOR FAST_FORWARD READ_ONLY FOR
SELECT 'DROP TABLE [' + s.name + '].[' + t.name + '];'
@zommarin
zommarin / gist:1236807
Created September 23, 2011 05:34 — forked from shbaz/gist:1188006
Size of tables in a SQL Server database
--
-- Count rows in all tables, display tables with rows
--
CREATE TABLE #T (
name NVARCHAR(255),
[rows] INT,
reserved NVARCHAR(255),
data NVARCHAR(255),
index_size NVARCHAR(255),
@zommarin
zommarin / gist:1236805
Created September 23, 2011 05:33 — forked from shbaz/gist:1188041
All objects not in dbo or sys schema
SELECT s.name, o.name, o.type, o.type_desc, s.schema_id
FROM sys.objects AS o
INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id
WHERE s.name NOT IN ( 'dbo', 'sys' )
@zommarin
zommarin / gist:1195238
Created September 5, 2011 15:23 — forked from shbaz/gist:1188369
git snippets
#
# Misc good to have commands when using git
#
# Setup user
git config --global user.name "First Last"
git config --global user.email first.last@domain.com
# Setup useful aliases
git config --global alias.ci commit