Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @MostRecentKeyId uniqueidentifier
- DECLARE @CurrentActiveKeyId uniqueidentifier
- --Get most recent CrmWRPCTokenKey
- SET @MostRecentKeyId =
- (SELECT top 1 id FROM CrmKey
- WHERE KeyType = 'CrmWRPCTokenKey'
- ORDER BY CreatedOn DESC)
- --Get the current ActiveKeyId
- SET @CurrentActiveKeyId =
- (SELECT ActiveKeyId FROM CrmKeySetting
- WHERE
- ActiveKeyId <> '00000000-0000-0000-0000-000000000000'
- AND KeyType = 'CrmWRPCTokenKey'
- AND IsConfigurationRow = 0)
- --Make sure the most recent CrmWRPCTokenKey = current ActiveKeyId
- IF @CurrentActiveKeyId <> @MostRecentKeyId
- BEGIN
- UPDATE CrmKeySetting
- SET ActiveKeyId = @MostRecentKeyId
- WHERE KeyType = 'CrmWRPCTokenKey'
- AND IsConfigurationRow = 0
- END
- ------------------------------------------------------------
- --Get most recent CrmTicketKey
- SET @MostRecentKeyId =
- (SELECT top 1 id FROM CrmKey
- WHERE KeyType = 'CrmTicketKey'
- ORDER BY CreatedOn DESC)
- --Get the current ActiveKeyId
- SET @CurrentActiveKeyId =
- (SELECT ActiveKeyId FROM CrmKeySetting
- WHERE
- ActiveKeyId <> '00000000-0000-0000-0000-000000000000'
- AND KeyType = 'CrmTicketKey'
- AND IsConfigurationRow = 0)
- --Make sure the most recent CrmTicketKey = current ActiveKeyId
- IF @CurrentActiveKeyId <> @MostRecentKeyId
- BEGIN
- UPDATE CrmKeySetting
- SET ActiveKeyId = @MostRecentKeyId
- WHERE KeyType = 'CrmTicketKey'
- AND IsConfigurationRow = 0
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement