MCITP

MCITP

Thursday, April 7, 2011

Search Object, Strings in database

CREATE FUNCTION [dbo].[FindStringTableDependency](@StrText varchar(500),@tableStrInd varchar(10))
RETURNS @tmpDepend TABLE (id varchar(100),Type varchar(10))
BEGIN
IF @tableStrInd <> 'T'
INSERT INTO @tmpDepend
SELECT DISTINCT name,xtype FROM sysobjects s INNER JOIN syscomments s2
ON s.id = s2.id WHERE s2.text LIKE '%'+ @strText + '%'
ELSE
INSERT INTO @tmpDepend
SELECT DISTINCT name,'T' FROM sysobjects WHERE id IN (
SELECT DISTINCT s.id FROM sysdepends s ,sysobjects o WHERE
s.depid = o.id AND o.name = '' + @StrText + '')

RETURN
END

No comments:

Post a Comment