Skip to content

Instantly share code, notes, and snippets.

@alexvy86
Last active October 9, 2015 03:48
Show Gist options
  • Save alexvy86/3433279 to your computer and use it in GitHub Desktop.
Save alexvy86/3433279 to your computer and use it in GitHub Desktop.
Look for DB objects with some text in them
DECLARE @textToLookFor VARCHAR(200)
SET @textToLookFor = 'InventoryTransaction'
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
WHERE OBJECT_DEFINITION(OBJECT_ID(ROUTINE_SCHEMA + '.' + ROUTINE_NAME)) LIKE '%' + @textToLookFor + '%'
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE OBJECT_DEFINITION(OBJECT_ID(TABLE_SCHEMA + '.' + TABLE_NAME)) LIKE '%' + @textToLookFor + '%'
SELECT * FROM INFORMATION_SCHEMA.VIEWS
WHERE OBJECT_DEFINITION(OBJECT_ID(TABLE_SCHEMA + '.' + TABLE_NAME)) LIKE '%' + @textToLookFor + '%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment