sqlserver刪除所有的使用者表

2021-06-10 00:52:59 字數 512 閱讀 4973

create procedure dbo.deletetable

as declare @name as nvarchar(128) 

declare curobject cursor for 

select   name   from   sysobjects   where   type='u'  and name like 'p%'

open curobject 

fetch next from curobject into @name 

while(@@fetch_status=0) 

begin 

print 'drop table '+@name

exec('drop table '+@name)

fetch next from curobject into @name

end 

close curobject 

deallocate curobject

go

所有的表sqlserver

select o.name as tablename,user name o.uid as owner,isnull ptb.value,n as tabledescription,c.colid as fieldid,c.name as fieldname,quotename t.name cas...

刪除所有的使用者表

1 刪除表的外來鍵約束 create procedure sp drop all fk as declare sql varchar 255 declare dropsql cursor cursor for select alter table object name fkeyid drop co...

Sql Server 刪除所有表

如果由於外來鍵約束刪除table失敗,則先刪除所有約束 第1步 刪除所有表的外來鍵約束 declarec1cursorfor select alter table object name parent obj drop constraint name fromsysobjects wherextyp...