标签:Owner sync for store data table parent procedure from
--1.generate the script to drop data sync tables
select ‘Drop table [DataSync].[‘+ st.name+ ‘];‘ from sys.tables as st join sys.schemas as ss on ss.schema_id = st.schema_id
where ss.name = ‘DataSync‘ and st.name like ‘%_dss%‘
--2.generate the script to drop data sync store procedures
select ‘Drop procedure [DataSync].[‘+ sp.name+ ‘];‘ from sys.procedures as sp join sys.schemas as ss on ss.schema_id = sp.schema_id
where ss.name = ‘DataSync‘ and sp.name like ‘%_dss_%‘
--3.delete datasync triggers if there is any
SELECT ‘Drop trigger [‘+s.name+‘].[‘+sysobjects.name+‘]‘,
sysobjects.name AS trigger_name
,USER_NAME(sysobjects.uid) AS trigger_owner
,s.name AS table_schema
,OBJECT_NAME(parent_obj) AS table_name
FROM sysobjects
INNER JOIN sysusers
ON sysobjects.uid = sysusers.uid
INNER JOIN sys.tables t
ON sysobjects.parent_obj = t.object_id
INNER JOIN sys.schemas s
ON t.schema_id = s.schema_id
WHERE sysobjects.type = ‘TR‘
and sysobjects.name like ‘%_dss%‘ and sysobjects.name like ‘%trigger‘
-4.generate script for dropping data sync-related udtt
select ‘Drop Type [DataSync].[‘+ st.name+ ‘];‘
from sys.types as st join
sys.schemas as ss on st.schema_id = ss.schema_id
where ss.name = ‘DataSync‘ and st.name like ‘%_dss_%‘
标签:Owner sync for store data table parent procedure from
原文地址:https://www.cnblogs.com/tliu/p/10145092.html