select 'ALTER TABLE [' + b.name + '] NOCHECK CONSTRAINT [' + a.name +'];'
from sysobjects a ,sysobjects b
where a.xtype ='f' and a.parent_obj = b.id
--or
select 'ALTER TABLE [' + name + '] NOCHECK CONSTRAINT all '
from sysobjects a
where a.xtype ='u'
--禁所有 器的 句
select 'ALTER TABLE [' + name + '] DISABLE TRIGGER all '
from sysobjects a
where a.xtype ='u'
-- 除所有表 料
/*
select 'TRUNCATE TABLE [' + a.name + '] '
from sysobjects a
where a.xtype ='u'
*/
--因 要加GO,在一 句 解 不了。
declare @name varchar(100)
declare cur cursor for
select name from sysobjects where xtype='u' order by name
open cur
fetch next from cur into @name
while @@fetch_status=0
begin
print 'TRUNCATE TABLE [' +@name + '] '
print 'GO'
fetch next from cur into @name
end
close cur
deallocate cur
/*
select 'DELETE [' + a.name + '] '
from sysobjects a
where a.xtype ='u'
*/
-- 是加Go的更好用。中 一 出 了也 有 系
declare @name varchar(100)
declare cur cursor for
select name from sysobjects where xtype='u' order by name
open cur
fetch next from cur into @name
while @@fetch_status=0
begin
print 'DELETE [' +@name + '] '
print 'GO'
fetch next from cur into @name
end
close cur
deallocate cur
-- 所有外 的 句
select 'ALTER TABLE [' + b.name + '] CHECK CONSTRAINT [' + a.name +'];'
from sysobjects a ,sysobjects b
where a.xtype ='f' and a.parent_obj = b.id
or
select 'ALTER TABLE [' + name + '] CHECK CONSTRAINT all '
from sysobjects a
where a.xtype ='u'
---- 所有 器的 句
select 'ALTER TABLE [' + name + '] enable TRIGGER all '
from sysobjects a
where a.xtype ='u'
--所有identity表 原 1的 句
select 'dbcc checkident(['+name+'],reseed ,0) '
from sysobjects a
where a.xtype ='u' and objectproperty(id,'TableHasIdentity')=1
--重建所有索引
select 'dbcc DBREINDEX(['+name+']) '
from sysobjects a
where a.xtype ='u'