jackbenson
asked on
In SEL SERVER 2005 is there a way to check column dependencies on a table
I want to make some changes to some tables in my database and i want to be able to see what Triggers, Foreign Keys, Stored Procedures, Views would be affected by the change.
I have tried EXEC sp_depends - but this shows dependancies of a table - but i want to try to get this information based on a specific column - how can i do this?
many thanks
jack
I have tried EXEC sp_depends - but this shows dependancies of a table - but i want to try to get this information based on a specific column - how can i do this?
many thanks
jack
ASKER
thanks for this - but it does not show column dependancy in:
Tiggers
Stored procedures
Tiggers
Stored procedures
ASKER
to confirm that i understand it correctly, if i use the following script the result will include Views, Stored Procedures, User Defined Functions, Constraints and Triggers [but not Foreign Keys] that are dependant on the EmployeeID Column in the tbl_Employee table:
SELECT DISTINCT sysobj.name
FROM syscomments
INNER JOIN sysobjects sysobj ON syscomments.id = sysobj.id
WHERE charindex('tbl_Employee.Em ployeeID', text) > 0
SELECT DISTINCT sysobj.name
FROM syscomments
INNER JOIN sysobjects sysobj ON syscomments.id = sysobj.id
WHERE charindex('tbl_Employee.Em
See the attachment. It will load all the dependencies and populate to a table.
You can query that table to get the result you want.
I hope this will help
LoadObjectDictionary.sql
You can query that table to get the result you want.
I hope this will help
LoadObjectDictionary.sql
ASKER
Rajvja,
thank-you for the script.
is there any documentation that goes with it?
Do i need to create a table called: DatabaseObjectDictionary to store the info in?
What should i set the value of: @strDBName_DwarfDB
What should i set the value of: @strDBName_DwarfPortable
Should the DwarfDB in the lines DwarfDB.dbo.syscommentsbe changed to my database name?
I have no idea what to do with: DwarfPortable.dbo.sysobjec ts - SQL server is thorwing an error when running this code
thanks
jack
thank-you for the script.
is there any documentation that goes with it?
Do i need to create a table called: DatabaseObjectDictionary to store the info in?
What should i set the value of: @strDBName_DwarfDB
What should i set the value of: @strDBName_DwarfPortable
Should the DwarfDB in the lines DwarfDB.dbo.syscommentsbe changed to my database name?
I have no idea what to do with: DwarfPortable.dbo.sysobjec
thanks
jack
Hi,
Belated reply. The script is commented. No need to populate to a table. It could be a temp table and your search cold be on that.
Chnage DwarfDB to ypur DB name.
DwarfPortable is also my database.
Belated reply. The script is commented. No need to populate to a table. It could be a temp table and your search cold be on that.
Chnage DwarfDB to ypur DB name.
DwarfPortable is also my database.
ASKER
I am really sorry to keep asking but i just dont get it.
what should these variables be set to?
Set @strDBName_DwarfDB = 'DwarfDB'
Set @strDBName_DwarfPortable = 'DwarfPortable'
Also - these:
DwarfDB.dbo.sysobjects
DwarfPortable.dbo.syscomme nts
if DwarfDB and DwarfPortable are borth database names - why are there two databases - i have only one?
Agan i am sorry if i am asking the obvious!
thanks
jack
what should these variables be set to?
Set @strDBName_DwarfDB = 'DwarfDB'
Set @strDBName_DwarfPortable = 'DwarfPortable'
Also - these:
DwarfDB.dbo.sysobjects
DwarfPortable.dbo.syscomme
if DwarfDB and DwarfPortable are borth database names - why are there two databases - i have only one?
Agan i am sorry if i am asking the obvious!
thanks
jack
ASKER
Hi
i have not it to work.
i just removed DwarfDB and DwarfPortable fromt eh lines below:
DwarfDB.dbo.sysobjects
DwarfPortable.dbo.syscomme nts
I set both of these to my database name:
Set @strDBName_DwarfDB = 'MyDB'
Set @strDBName_DwarfPortable = 'MyDB'
it returns every result twice but it works.
thanks
jack
i have not it to work.
i just removed DwarfDB and DwarfPortable fromt eh lines below:
DwarfDB.dbo.sysobjects
DwarfPortable.dbo.syscomme
I set both of these to my database name:
Set @strDBName_DwarfDB = 'MyDB'
Set @strDBName_DwarfPortable = 'MyDB'
it returns every result twice but it works.
thanks
jack
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://blogs.msdn.com/sqltips/archive/2005/07/05/435882.aspx