Skip to content

Instantly share code, notes, and snippets.

@ewoo
Created October 8, 2015 18:09
Show Gist options
  • Save ewoo/eb582155d5572ec15faa to your computer and use it in GitHub Desktop.
Save ewoo/eb582155d5572ec15faa to your computer and use it in GitHub Desktop.
Search for a specific string inside a SQL View object.
DECLARE @search VARCHAR(1000)
SET @search = '%friendly%'
SELECT v.name, c.[Text]
FROM dbo.sysobjects AS v
INNER JOIN dbo.syscomments c ON c.id = v.id
AND CASE WHEN c.Number > 1 THEN c.Number
ELSE 0 END = 0
WHERE v.type = 'V' AND c.[Text] LIKE '%' + @search + '%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment