SQL语句: 改变数据表的架构

时间:2009-07-06 阅读: 随风缘
SQL2000: sp_configure 'allow updates','1' go reconfigure with override go update sysobjects set uid=1 where uid go sp_configure 'allow updates','0' go reconfigure with override SQL2005: declare @name sysname declare csr1 cursor for select TABLE_NAME from INFORMATION_SCHEMA.TABLES open csr1 FETCH NEXT FROM csr1 INTO @name while (@@FETCH_STATUS=0) BEGIN SET @name='旧

SQL2000:

sp_configure 'allow updates','1'
go
reconfigure with override
go
update sysobjects set uid=1 where uid<>1
go
sp_configure 'allow updates','0'
go
reconfigure with override

 

 

SQL2005:

declare @name sysname
declare csr1 cursor
for
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
open csr1

FETCH NEXT FROM csr1 INTO @name
while (@@FETCH_STATUS=0)
BEGIN
SET @name='旧的架构名称.' + @name

print 'Alter SCHEMA dbo TRANSFER ' + @name
fetch next from csr1 into @name
END
CLOSE csr1
DEALLOCATE csr1

[责任编辑:jumbot]

[发表评论] [收藏本页]