Jeff S
asked on
SQL 2005 Coding question
How can I scan all my tables against my db and find the ones that contain a specific fieldname? I want to find all instances were I have a field name "PreviousPatientProfileId"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use this
USE <YOUR DATABASE>;
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
COLUMN_NAME = 'PreviousPatientProfileId';
I would Also suggest:
(This will search all your stored procs to see if you are using the field there as well
(This will search all your stored procs to see if you are using the field there as well
declare @Text nvarchar(100)
set @Text = '%PreviousPatientProfileId%'
SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE @Text
AND OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)
ASKER
THANKS!
Open in new window