008_UserStore.sql 994 B

1234567891011121314151617181920212223242526272829
  1. BEGIN TRANSACTION
  2. CREATE TABLE dbo.Tmp_userfriends
  3. (
  4. ownerID uniqueidentifier NOT NULL,
  5. friendID uniqueidentifier NOT NULL,
  6. friendPerms int NOT NULL,
  7. datetimestamp int NOT NULL
  8. ) ON [PRIMARY]
  9. IF EXISTS(SELECT * FROM dbo.userfriends)
  10. EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp)
  11. SELECT CONVERT(uniqueidentifier, ownerID), CONVERT(uniqueidentifier, friendID), friendPerms, datetimestamp FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
  12. DROP TABLE dbo.userfriends
  13. EXECUTE sp_rename N'dbo.Tmp_userfriends', N'userfriends', 'OBJECT'
  14. CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON dbo.userfriends
  15. (
  16. ownerID
  17. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  18. CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON dbo.userfriends
  19. (
  20. friendID
  21. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  22. COMMIT