Created
October 2, 2018 07:24
-
-
Save arnabdas/34095d32c8f0e5b54a12f64a5fa01298 to your computer and use it in GitHub Desktop.
Useful tsql scripts taken from around the net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get the sp text | |
DECLARE @Lines TABLE (Line NVARCHAR(MAX)) ; | |
DECLARE @FullText NVARCHAR(MAX) = '' ; | |
INSERT @Lines EXEC sp_helptext 'sp_ProcedureName' ; | |
SELECT @FullText = @FullText + Line FROM @Lines ; | |
PRINT @FullText ; | |
-- Get db and table sizes | |
select | |
sum(reserved_page_count) * 8.0 / 1024 [SizeInMB] | |
from | |
sys.dm_db_partition_stats | |
GO | |
select | |
sys.objects.name, sum(reserved_page_count) * 8.0 / 1024 [SizeInMB] | |
from | |
sys.dm_db_partition_stats, sys.objects | |
where | |
sys.dm_db_partition_stats.object_id = sys.objects.object_id | |
group by sys.objects.name | |
order by sum(reserved_page_count) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment