004_EstateStore.sql 660 B

12345678910111213141516171819202122
  1. BEGIN TRANSACTION
  2. CREATE TABLE dbo.Tmp_estate_managers
  3. (
  4. EstateID int NOT NULL,
  5. uuid uniqueidentifier NOT NULL
  6. ) ON [PRIMARY]
  7. IF EXISTS(SELECT * FROM dbo.estate_managers)
  8. EXEC('INSERT INTO dbo.Tmp_estate_managers (EstateID, uuid)
  9. SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_managers WITH (HOLDLOCK TABLOCKX)')
  10. DROP TABLE dbo.estate_managers
  11. EXECUTE sp_rename N'dbo.Tmp_estate_managers', N'estate_managers', 'OBJECT'
  12. CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
  13. (
  14. EstateID
  15. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  16. COMMIT