SQL2000中指定位置插入列的处理方法:
系统的处理很简单,建一个新表Tmp_test,把旧表test的数据全部插入到新表中,然后删除test,把Tmp_test改名为test,代码如下:
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_test
(
a char(10) NULL,
b char(10) NULL,
c char(10) NULL,
d char(10) NULL
) ON [PRIMARY]
GO
IF EXISTS(SELECT * FROM dbo.test)
EXEC('INSERT INTO dbo.Tmp_test (a, c, d)
SELECT a, c, d FROM dbo.test (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.test
GO
EXECUTE sp_rename N'dbo.Tmp_test', N'test', 'OBJECT'
GO
COMMIT