2012年2月2日 星期四
Truncate資料庫裡全部資料表
USE db_name
SELECT table_name into #a01 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
declare @name nvarchar(1000)
declare ID1 cursor for
SELECT * FROM #a01
OPEN ID1
FETCH NEXT FROM ID1 into @name
WHILE(@@FETCH_STATUS=0)
BEGIN
IF EXISTS(SELECT * FROM SYSOBJECTS WHERE NAME=@name)
EXEC('truncate table [' + @name + ']')
FETCH NEXT FROM ID1
INTO @name
END
更改資料表的擁有者sp_changeobjectowner
語法: sp_changeobjectowner [ @objname = ] 'object', [ @newowner = ] 'owner'
範例: 將'author' 資料表擁有者變更為'george'
EXEC sp_changeobjectowner 'authors' , 'george'
http://msdn.microsoft.com/zh-tw/library/ms177519.aspx
範例: 將'author' 資料表擁有者變更為'george'
EXEC sp_changeobjectowner 'authors' , 'george'
http://msdn.microsoft.com/zh-tw/library/ms177519.aspx
訂閱:
文章 (Atom)