然后在MicrosoftSQLServerManagementStudio中在该表的ID列与Name列中拔出varchar(50)列UserID,然后点击天生变动剧本,天生的剧本以下:
/*为了避免任何大概呈现的数据丧失成绩,您应当先细心反省此剧本,然后再在数据库计划器的高低文以外运转此剧本。*/
BEGINTRANSACTION
SETQUOTED_IDENTIFIERON
SETARITHABORTON
SETNUMERIC_ROUNDABORTOFF
SETCONCAT_NULL_YIELDS_NULLON
SETANSI_NULLSON
SETANSI_PADDINGON
SETANSI_WARNINGSON
COMMIT
BEGINTRANSACTION
GO
CREATETABLEdbo.Tmp_Table_1
(
IDintNOTNULLIDENTITY(1,1),
UserIDvarchar(50)NULL,
Namevarchar(50)NULL
)ON[PRIMARY]
GO
SETIDENTITY_INSERTdbo.Tmp_Table_1ON
GO
IFEXISTS(SELECT*FROMdbo.Table_1)
EXEC(INSERTINTOdbo.Tmp_Table_1(ID,Name)
SELECTID,NameFROMdbo.Table_1WITH(HOLDLOCKTABLOCKX))
GO
SETIDENTITY_INSERTdbo.Tmp_Table_1OFF
GO
DROPTABLEdbo.Table_1
GO
EXECUTEsp_renameNdbo.Tmp_Table_1,NTable_1,OBJECT
GO
COMMIT