Make sure server was started in single user mode (or that sp_configure?)
was used to enable updates to system tables.
***/
if (select value from syscurconfigs where config = 102) <> 1
raiserror('Cannot run this file unless updates to system tables are enabled. Shutdown server and restart with the ''-m'' option to enable updates to system tables.'
,22,127) with log
Go
if object_id('#prc_dropall_1') is not null
drop procedure #prc_dropall_1
Go
create procedure #prc_dropall_1
as
set nocount on
Declare
@obj_type char(2)
,@obj_name varchar(64)
,@count_1 integer
,@count_2 integer
,@dump_size integer
,@dyn_cmd varchar(127)
,@BitMSObj integer
Select @dump_size = 25
select 'db_name()=',db_name()
Print 'Object type counts immediately prior to the drops:'
Select type ,count(*) as 'Count_10' from sysobjects
where ObjectProperty(id, 'IsMSShipped') = 1
group by type order by type
Print ' '
DECLARE
csr_17_todrop
insensitive
Cursor For
SELECT
obj.type
,obj.name
from
sysobjects obj
where ObjectProperty(obj.id, 'IsMSShipped') = 1
AND (type != 'V' OR substring(name, 1, 3) != 'sys')
order by
obj.type
,obj.name
FOR read only
Open csr_17_todrop
Select @count_1=0 ,@count_2=0
WHILE (17=17)
begin
FETCH next
from csr_17_todrop
into @obj_type
,@obj_name
if (@@fetch_status <> 0)
begin
Deallocate csr_17_todrop
BREAK
end
select @count_1 = @count_1 + 1
if (@count_1 % (@dump_size) = 0)
begin
select @count_2 = @count_2 + @count_1
raiserror('So far %d Microsoft supplied sysobjects have been dropped.',0,1,@count_2) with nowait
select @count_1=0
dump transaction master with no_log
end
select @dyn_cmd = '/' + '* pre case init *' + '/'
select @dyn_cmd =
case @obj_type
when 'P ' then 'drop procedure ' + @obj_name
when 'U ' then 'drop table ' + @obj_name
when 'TR' then 'drop trigger ' + @obj_name
when 'V ' then 'drop view ' + @obj_name
when 'X ' then 'dbcc dropextendedproc(''' + @obj_name + ''')'
else '/' + '* Bypassing type=' +@obj_type+
' name=' +@obj_name+ ' *' + '/'
end
if (@obj_type = 'U ') --Might contain user data.
begin
if NOT (@obj_name in ( --Only these 'U ' can be dropped.
'spt_values' ,'spt_monitor'
,'spt_datatype_info' ,'spt_datatype_info_ext'
,'spt_server_info'
)
)
begin
raiserror('/* Bypassing type=%s name=%s, to avoid loss of user data. */'
,0,1,@obj_type,@obj_name)
CONTINUE
end
end
print @dyn_cmd
EXECUTE(@dyn_cmd)
end -- loop 17
Print ' '
Print 'Object type counts immediately after dynamic drop logic:'
Select type,count(*) 'Count_30' from sysobjects
where ObjectProperty(id, 'IsMSShipped') = 1
group by type order by type
Print ' '
--End of #prc_dropall_1 creation...
Go
------------------------ Run drops in some databases --------------
use master
go
execute #prc_dropall_1
go
declare @dbname varchar(30)
select @dbname = 'msdb'
if exists (select * from master..sysdatabases where name=@dbname)
begin
execute('use ' +@dbname+ ' exec #prc_dropall_1')
end
Go
use master
Go
if object_id('tempdb..#prc_dropall_1') is not null
drop procedure #prc_dropall_1
Go
---------- Special cases, and Hardcoded cases -------------------
Go
if object_id('sp_dbcoalesce','P') IS NOT NULL
begin
print 'Dropping procedure sp_dbcoalesce (obsolete in MS SQL 6.5) ...'
drop procedure sp_dbcoalesce
end
else
begin
print 'Nonexistent is procedure sp_dbcoalesce.'
end
-- Above were special cases.
Print ' '
Go
if object_id('MS_sqlctrs_users','P') IS NOT NULL
begin
print 'Dropping procedure MS_sqlctrs_users ...'
drop procedure MS_sqlctrs_users
end
else
begin
print 'Nonexistent is procedure MS_sqlctrs_users.'
end
if object_id('sp_a_count_bits_on','P') IS NOT NULL
begin
print 'Dropping procedure sp_a_count_bits_on ...'
drop procedure sp_a_count_bits_on
end
else
begin
print 'Nonexistent is procedure sp_a_count_bits_on.'
end
if object_id('sp_abort_xact','P') IS NOT NULL
begin
print 'Dropping procedure sp_abort_xact ...'
drop procedure sp_abort_xact
end
else
begin
print 'Nonexistent is procedure sp_abort_xact.'
end
if object_id('sp_addalias','P') IS NOT NULL
begin
print 'Dropping procedure sp_addalias ...'
drop procedure sp_addalias
end
else
begin
print 'Nonexistent is procedure sp_addalias.'
end
if object_id('sp_addarticle','P') IS NOT NULL
begin
print 'Dropping procedure sp_addarticle ...'
drop procedure sp_addarticle
end
else
begin
print 'Nonexistent is procedure sp_addarticle.'
end
Go
Dump Transaction master with no_log
Go
if object_id('sp_addextendedproc','P') IS NOT NULL
begin
print 'Dropping procedure sp_addextendedproc ...'
drop procedure sp_addextendedproc
end
else
begin
print 'Nonexistent is procedure sp_addextendedproc.'
end
if object_id('sp_addgroup','P') IS NOT NULL
begin
print 'Dropping procedure sp_addgroup ...'
drop procedure sp_addgroup
end
else
begin
print 'Nonexistent is procedure sp_addgroup.'
end
if object_id('sp_addlogin','P') IS NOT NULL
begin
print 'Dropping procedure sp_addlogin ...'
drop procedure sp_addlogin
end
else
begin
print 'Nonexistent is procedure sp_addlogin.'
end
if object_id('sp_addmessage','P') IS NOT NULL
begin
print 'Dropping procedure sp_addmessage ...'
drop procedure sp_addmessage
end
else
begin
print 'Nonexistent is procedure sp_addmessage.'
end
Go
if object_id('sp_addpublication','P') IS NOT NULL
begin
print 'Dropping procedure sp_addpublication ...'
drop procedure sp_addpublication
end
else
begin
print 'Nonexistent is procedure sp_addpublication.'
end
if object_id('sp_addpublisher','P') IS NOT NULL
begin
print 'Dropping procedure sp_addpublisher ...'
drop procedure sp_addpublisher
end
else
begin
print 'Nonexistent is procedure sp_addpublisher.'
end
if object_id('sp_addremotelogin','P') IS NOT NULL
begin
print 'Dropping procedure sp_addremotelogin ...'
drop procedure sp_addremotelogin
end
else
begin
print 'Nonexistent is procedure sp_addremotelogin.'
end
if object_id('sp_addsegment','P') IS NOT NULL
begin
print 'Dropping procedure sp_addsegment ...'
drop procedure sp_addsegment
end
else
begin
print 'Nonexistent is procedure sp_addsegment.'
end
if object_id('sp_addserver','P') IS NOT NULL
begin
print 'Dropping procedure sp_addserver ...'
drop procedure sp_addserver
end
else
begin
print 'Nonexistent is procedure sp_addserver.'
end
Go
Dump Transaction master with no_log
Go
if object_id('sp_addsubscriber','P') IS NOT NULL
begin
print 'Dropping procedure sp_addsubscriber ...'
drop procedure sp_addsubscriber
end
else
begin
print 'Nonexistent is procedure sp_addsubscriber.'
end
if object_id('sp_addsubscription','P') IS NOT NULL
begin
print 'Dropping procedure sp_addsubscription ...'
drop procedure sp_addsubscription
end
else
begin
print 'Nonexistent is procedure sp_addsubscription.'
end
if object_id('sp_addtype','P') IS NOT NULL
begin
print 'Dropping procedure sp_addtype ...'
drop procedure sp_addtype
end
else
begin
print 'Nonexistent is procedure sp_addtype.'
end
if object_id('sp_addumpdevice','P') IS NOT NULL
begin
print 'Dropping procedure sp_addumpdevice ...'
drop procedure sp_addumpdevice
end
else
begin
print 'Nonexistent is procedure sp_addumpdevice.'
end
if object_id('sp_adduser','P') IS NOT NULL
begin
print 'Dropping procedure sp_adduser ...'
drop procedure sp_adduser
end
else
begin
print 'Nonexistent is procedure sp_adduser.'
end
Go
if object_id('sp_altermessage','P') IS NOT NULL
begin
print 'Dropping procedure sp_altermessage ...'
drop procedure sp_altermessage
end
else
begin
print 'Nonexistent is procedure sp_altermessage.'
end
if object_id('sp_articlecolumn','P') IS NOT NULL
begin
print 'Dropping procedure sp_articlecolumn ...'
drop procedure sp_articlecolumn
end
else
begin
print 'Nonexistent is procedure sp_articlecolumn.'
end
if object_id('sp_articlefilter','P') IS NOT NULL
begin
print 'Dropping procedure sp_articlefilter ...'
drop procedure sp_articlefilter
end
else
begin
print 'Nonexistent is procedure sp_articlefilter.'
end
if object_id('sp_articletextcol','P') IS NOT NULL
begin
print 'Dropping procedure sp_articletextcol ...'
drop procedure sp_articletextcol
end
else
begin
print 'Nonexistent is procedure sp_articletextcol.'
end
if object_id('sp_articleview','P') IS NOT NULL
begin
print 'Dropping procedure sp_articleview ...'
drop procedure sp_articleview
end
else
begin
print 'Nonexistent is procedure sp_articleview.'
end
Go
Dump Transaction master with no_log
Go
if object_id('sp_bindefault','P') IS NOT NULL
begin
print 'Dropping procedure sp_bindefault ...'
drop procedure sp_bindefault
end
else
begin
print 'Nonexistent is procedure sp_bindefault.'
end
if object_id('sp_bindrule','P') IS NOT NULL
begin
print 'Dropping procedure sp_bindrule ...'
drop procedure sp_bindrule
end
else
begin
print 'Nonexistent is procedure sp_bindrule.'
end
if object_id('sp_blockcnt','P') IS NOT NULL
begin
print 'Dropping procedure sp_blockcnt ...'
drop procedure sp_blockcnt
end
else
begin
print 'Nonexistent is procedure sp_blockcnt.'
end
if object_id('sp_certify_removable','P') IS NOT NULL