Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created April 22, 2014 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrijac/11169569 to your computer and use it in GitHub Desktop.
Save andrijac/11169569 to your computer and use it in GitHub Desktop.
Find line count in SQL server stored procedures.
SELECT o.type_desc AS ROUTINE_TYPE
,QUOTENAME(s.[name]) + '.' + QUOTENAME(o.[name]) AS [OBJECT_NAME]
,(LEN(m.definition) - LEN(REPLACE(m.definition, CHAR(10), ''))) AS LINES_OF_CODE
FROM sys.sql_modules AS m
INNER JOIN sys.objects AS o
ON m.[object_id] = o.[OBJECT_ID]
INNER JOIN sys.schemas AS s
ON s.[schema_id] = o.[schema_id]
order by LINES_OF_CODE desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment