Reputation: 175
I am making a query to lists down all stored procedures which contains an insert statement for a table.
Query doesn't give result if '[' is used in like statement.
SELECT Name,OBJECT_DEFINITION(object_id)
FROM sys.procedures WHERE OBJECT_DEFINITION(object_id) LIKE '%[dbo].[TABLE]%'
Problem is with '[', but not able to get it solved.
Upvotes: 0
Views: 99
Reputation: 11893
Try this:
SELECT Name,OBJECT_DEFINITION(object_id)
FROM sys.procedures WHERE OBJECT_DEFINITION(object_id) LIKE '%[[]dbo].[[]TABLE]%'
which escapes each instance of '[' by replacing it with '[[]'.
Upvotes: 1