1
0

002_AssetStore.sql 815 B

1234567891011121314151617181920212223242526272829
  1. BEGIN TRANSACTION
  2. CREATE TABLE Tmp_assets
  3. (
  4. id varchar(36) NOT NULL,
  5. name varchar(64) NOT NULL,
  6. description varchar(64) NOT NULL,
  7. assetType tinyint NOT NULL,
  8. local bit NOT NULL,
  9. temporary bit NOT NULL,
  10. data image NOT NULL
  11. ) ON [PRIMARY]
  12. TEXTIMAGE_ON [PRIMARY]
  13. IF EXISTS(SELECT * FROM assets)
  14. EXEC('INSERT INTO Tmp_assets (id, name, description, assetType, local, temporary, data)
  15. SELECT id, name, description, assetType, CONVERT(bit, local), CONVERT(bit, temporary), data FROM assets WITH (HOLDLOCK TABLOCKX)')
  16. DROP TABLE assets
  17. EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
  18. ALTER TABLE dbo.assets ADD CONSTRAINT
  19. PK__assets__id PRIMARY KEY CLUSTERED
  20. (
  21. id
  22. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  23. COMMIT