개발/MS-SQL

mssql 스키마 변경(테이블 전체)

쭈니후니 2014. 2. 18. 10:06

use db명

go

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 스키마명.'+@tbname;
 exec(@sql);
 fetch next from c into @tbname;
end
close c;
deallocate c;