상세 컨텐츠

본문 제목

스키마 변경

DataBase/SQL Server

by 탑~! 2008. 7. 14. 09:19

본문

declare @sql as nvarchar(100);

declare @tbname as nvarchar(100);

declare c cursor fast_forward for
select [name] from sysobjects where xtype = 'u' or xtype = 'p' order by name;
open c;
fetch next from c into @tbname;

while @@fetch_status = 0
begin
 set @sql = 'ALTER SCHEMA  dbo transfer devpia.' + @tbname ;
 exec(@sql);
 fetch next from c into @tbname;
end
close c;
deallocate c;

----스키마메타정보
--SELECT *
--FROM INFORMATION_SCHEMA.SCHEMATA
--WHERE SCHEMA_NAME = '';
--
----스키마정보 수정 예
--ALTER SCHEMA dbo TRANSFER Devpia.test;

관련글 더보기