1
0

004_UserStore.sql 982 B

1234567891011121314151617181920212223242526272829
  1. BEGIN TRANSACTION
  2. CREATE TABLE Tmp_userfriends
  3. (
  4. ownerID varchar(36) NOT NULL,
  5. friendID varchar(36) NOT NULL,
  6. friendPerms int NOT NULL,
  7. datetimestamp int NOT NULL
  8. ) ON [PRIMARY]
  9. IF EXISTS(SELECT * FROM userfriends)
  10. EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp)
  11. SELECT CONVERT(varchar(36), ownerID), CONVERT(varchar(36), friendID), CONVERT(int, friendPerms), CONVERT(int, datetimestamp) FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
  12. DROP TABLE dbo.userfriends
  13. EXECUTE sp_rename N'Tmp_userfriends', N'userfriends', 'OBJECT'
  14. CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON 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 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