摘要:
declare tb cursor local forselect 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].['+replace(name,']',']]')+']'',''dbo'''from sysobjects where xtype in('U','V','P','TR','FN','IF','TF') ... 阅读全文
摘要:
使用游标逐个清空表declare tempCursor cursor forselect name from sysobjects where type='U'--获取数据库中所有表名:‘U’表示用户表open tempCursordeclare @tbName varchar(50)fetch next from tempCursorinto @tbNamewhile @@fetch_status=0begin exec('truncate table '+ @tbName )fetch next from tempCursorinto @tbNameend close tempCursor 阅读全文