Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Find Column Usage


Find Column Usage

Author
Message
kgayda
kgayda
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 172
Comments posted to this topic are about the item Find Column Usage


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
PCI
PCI
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 42
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 !



kgayda
kgayda
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 172
I think you have mistaken this with another post.


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
dhawalbatavia
dhawalbatavia
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 139
Thanks for the wonderful post, this is exactly what i was looking to implement. Good job.
kgayda
kgayda
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 172
Thank you.


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
stephen.hendricks
stephen.hendricks
Old Hand
Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)Old Hand (315 reputation)

Group: General Forum Members
Points: 315 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)
kgayda
kgayda
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 172
I suppose that is a possibility but I have not encountered it yet.


Karen Gayda
MCP, MCSD, MCDBA

gaydaware.com
Mitch Rosenberg-300103
Mitch Rosenberg-300103
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 167
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]


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search