November 9, 2006 at 1:40 pm
yes; my original post about sp_MSdependencies is the solution;
create table #Hierarchy (
objectType int,
objectName varchar(50),
objectOwner varchar(50),
CreationOrder int,
IsSchemaBound int)
insert into #Hierarchy (objectType,objectName,objectOwner,CreationOrder)
EXEC sp_msdependencies @intrans = 1
select * from #Hierarchy
update #Hierarchy set IsSchemaBound = OBJECTPROPERTY(OBJECT_ID(objectName), 'IsSchemaBound') where objectType=4 --views!
select * from #Hierarchy where objectType=4 and IsSchemaBound=0 order by CreationOrder
so you use this for your cursor instead:
select objectName from #Hierarchy where objectType=4 and IsSchemaBound=0 order by CreationOrder
to generate the scripts in the correct order:
SET NOCOUNT ON
SELECT 'EXEC SP_HELPTEXT ' + objectName from #Hierarchy where objectType=4 and IsSchemaBound=0 order by CreationOrder
run the results, and that creates the non-schema bound scripts in the right order for the views in question.
If it's not obvious, you could do the same for tables, procedures or functions in the same way.
Lowell
Viewing post 16 (of 15 total)
You must be logged in to reply to this topic. Login to reply