|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 19, 2011 5:10 PM
Points: 275,
Visits: 168
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, November 02, 2011 9:50 AM
Points: 15,
Visits: 30
|
|
You have just a little problem with this.
If the column name is not present in the SELECT section, but it's there in the WHERE clause,
The stored procedure ignore this case.
With this example:
CREATE FUNCTION dbo.ufGetUserID (@p_Username varchar(20))
RETURNS int as
RETURN (
SELECT usrID
FROM TB_usrUser
WHERE usrName = @p_Username
)
The function ufGetUserID is never returning,
Because you search the column name before the table name !
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 19, 2011 5:10 PM
Points: 275,
Visits: 168
|
|
I think you have mistaken this with another post.
Karen Gayda MCP, MCSD, MCDBA
gaydaware.com
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Today @ 12:43 PM
Points: 7,
Visits: 136
|
|
| Thanks for the wonderful post, this is exactly what i was looking to implement. Good job.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 19, 2011 5:10 PM
Points: 275,
Visits: 168
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, August 07, 2009 5:46 PM
Points: 295,
Visits: 67
|
|
Does the script account for the possibility that the column name might cross a syscomments boundary (e.g., Part of the column name is at the end of syscomments.Row1 while the rest of the column name begins syscomments.row2) or do you feel that this condition won't occur?
============================================================ I believe I found the missing link between animal and civilized man. It is us. -Konrad Lorenz, Nobel laureate (1903-1989)
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 19, 2011 5:10 PM
Points: 275,
Visits: 168
|
|
I suppose that is a possibility but I have not encountered it yet.
Karen Gayda MCP, MCSD, MCDBA
gaydaware.com
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 10:15 AM
Points: 1,
Visits: 117
|
|
This may work better for the trigger references:
SELECT DISTINCT SUBSTRING( SO.NAME, 1, 60 ) AS [Trigger Name] FROM sysobjects AS SO JOIN syscomments AS SC ON SO.ID = SC.ID WHERE SO.XTYPE = 'TR' AND SC.Text LIKE '%' + @vcColumnName + '%' AND ( @vcTableName = '' OR OBJECT_NAME( SO.Parent_Obj ) = @vcTableName ) ORDER BY [Trigger Name]
|
|
|
|