소유자 변경
sp_changeobjectowner '소유자.테이블명', '소유자아이디'

 


데이타베이스 이름 변경
sp_renamedb '이전이름', '새로운 이름'



[테이블 소유주 권한 한방에 바꾸기]
DECLARE @TABLE_NAME VARCHAR (50)
DECLARE @TABLE_OWNER VARCHAR (50)
DECLARE TCURSOR CURSOR
 
FOR SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'
FOR READ ONLY
 
OPEN TCURSOR FETCH NEXT FROM TCURSOR INTO @TABLE_NAME, @TABLE_OWNER
WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC ('SP_CHANGEOBJECTOWNER ''[' + @TABLE_OWNER + '].[' + @TABLE_NAME + ']'', ''well''')
    FETCH NEXT FROM TCURSOR INTO @TABLE_NAME, @TABLE_OWNER
END
CLOSE TCURSOR
DEALLOCATE TCURSOR

+ Recent posts