April 1, 2008 at 1:51 pm
Hi
I am trying to move objects,Sps,views,Udfs from one database to another meaning cleaning the junk.is there any script that I could find Tables,Sps.views udf's dependencies and than recreate the necessary objects in order in another database.
April 1, 2008 at 7:41 pm
sys.sysdepends has the dependency information.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 2, 2008 at 3:27 am
In case if your using SQL Server 2005, use sys.sql_dependencies.
Remember, there are some situations you will not find dependies recorded in the system view. Specially when you rename an object, dependancies will not update.
Susantha
April 2, 2008 at 5:50 am
Ordering the objects by creation date will get you most of the way there.
Nigel Moore
======================
April 3, 2008 at 10:35 am
salibindla_m (4/1/2008)
HiI am trying to move objects,Sps,views,Udfs from one database to another meaning cleaning the junk.is there any script that I could find Tables,Sps.views udf's dependencies and than recreate the necessary objects in order in another database.
I you are scripting them all to a single batch, then you can use a BEGIN TRANSACTION at the top of the script, and a ROLLBACK TRANSACTION at the bottom of the script. Run and reorganize until there are no more missing dependencies messages. Then commit the batch.
April 6, 2008 at 1:24 am
Select name, Category =
CASE xType
WHEN 'P'THEN 'Stored procedure'
WHEN 'TR'THEN 'Trigger'
WHEN 'V'THEN 'View'
WHEN 'U'THEN 'User table'
WHEN 'TF'THEN 'Table function'
ELSE 'Not yet categorized'
END
from sysobjects
where ID in
(
Select id from sysdepends
where
depid = (Select ID from sysobjects so2 where name = @SysObject)
)
and xType in ('P', 'TR', 'V', 'U', 'TF')
UNION
Select
(Select name from sysobjects so where so.id = sf.fkeyid)
, 'FOREIGN KEY'
from dbo.sysforeignkeys sf -- use dbo instead of sys for backward compatibility
where sf.rKeyid =
(
Select ID from sysobjects where name= @SysObject
)
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply