The SQL Server Management studio manager is really cheap. It was accidentally discovered today by using the script tracker.
I modified the rowflag field int to bit for a field type.
The SMS manager did this.
For example, table name: ABC
1. Create a temporary table based on the field structure modified by ABC and name it tmp_abc.
It does this.
CREATE TABLE dbo.Tmp_ABC( ID uniqueidentifier NOT NULL, ServerIP varchar(20) NULL, AccountName nvarchar(50) NULL, StaffID int NULL, StaffName nvarchar(50) NULL, GroupID int NULL, GroupName nvarchar(200) NULL, Remark nvarchar(MAX) NULL, OperatorName nvarchar(50) NULL, RecFlag tinyint NULL, OperatorTime datetime NULL, RowFlag bit NULL) ON [PRIMARY]TEXTIMAGE_ON [PRIMARY]
2.Insert all data of ABC into from tmp_abc table
It does this (it's a little scary)
IF EXISTS(SELECT * FROM dbo.ABC)EXEC('INSERT INTO dbo.Tmp_ABC(ID, ServerIP, AccountName, StaffID, StaffName, GroupID, GroupName, Remark, OperatorName, RecFlag, OperatorTime, RowFlag)SELECT ID, ServerIP, AccountName, StaffID, StaffName, GroupID, GroupName, Remark, OperatorName, RecFlag, OperatorTime, CONVERT(bit, RowFlag) FROM dbo.ABC WITH (HOLDLOCK TABLOCKX)')
3. Delete ABC and change the tmp_abc name to ABC.
It does this.
DROP TABLE dbo.ABCEXECUTE
sp_rename N'dbo.Tmp_ABC', N'ABC', 'OBJECT'
4. Get all ABC attributes, foreign keys, descriptions, and relationships to the tmp_abc temporary table.
It does this.
ALTER TABLE dbo.ABC ADD CONSTRAINT PK_AccountRec PRIMARY KEY CLUSTERED ( ID ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
And so on.
If this table requires a lot of data, it will not be a tragedy ..
I'm so convinced of Microsoft's software engineer. It's a good task of stealing.