Modify Column Identity

Source: Internet
Author: User

/* To prevent any possible data loss problems, you should review this script carefully before running the script outside the context of the Database Designer. */
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
GO
CREATE TABLE dbo. Tmp_trans
(
ID int not NULL IDENTITY (1, 1),
Trans_time datetime NULL,
Sales Decimal (2) NULL
) on [PRIMARY]
GO
ALTER TABLE dbo. Tmp_trans SET (lock_escalation = TABLE)
GO
SET IDENTITY_INSERT dbo. Tmp_trans on
GO
IF EXISTS (SELECT * from Dbo.trans)
EXEC (' INSERT into dbo '. Tmp_trans (ID, trans_time, sales)
SELECT ID, trans_time, sales from Dbo.trans with (HOLDLOCK Tablockx) ')
GO
SET IDENTITY_INSERT dbo. Tmp_trans OFF
GO
DROP TABLE Dbo.trans
GO
EXECUTE sp_rename N ' dbo. Tmp_trans ', N ' trans ', ' OBJECT '
GO
COMMIT

Modify Column Identity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.