Deleting SQL2005 Java Schema for SAP
April 2, 2012 at 4:38 pm Leave a comment
declare @schema varchar(200)
select @schema = ‘SAPTRNDB’
select
‘DROP ‘ + case
when o.xtype = ‘U’ then ‘TABLE’
when o.xtype = ‘V’ then ‘VIEW’
when o.xtype = ‘P’ then ‘PROCEDURE’
when o.xtype = ‘FN’ then ‘FUNCTION’
end + ‘ ‘ + s.name + ‘.’ + o.name as SQL
from
sys.sysobjects as o
join sys.schemas as s on o.uid = s.schema_id
where
s.name = @schema and
o.xtype in (‘U’,’V’,’P’,’FN’)
union all
select
‘DROP SCHEMA ‘ + @schema
Entry filed under: Uncategorized.
Trackback this post | Subscribe to the comments via RSS Feed