Further refined Find Text in Column Name

Now returns table (or function which returns a table) and column name.


CREATE FUNCTION Find_Text_In_Column_Name (@StringToSearch varchar(100))
RETURNS @fColumnNames TABLE (tablename sysname, colname sysname)
AS
BEGIN
SET @StringToSEarch = '%' + @StringToSearch + '%'
INSERT @fColumnNames
SELECT DISTINCT SO.NAME, SC.NAME
FROM syscolumns SC (NOLOCK)
INNER JOIN
sysobjects SO (NOLOCK)
ON SC.id = SO.id
WHERE SC.NAME LIKE @StringToSearch
ORDER BY SC.Name
RETURN
END