Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Add table with all partyIDS
- SELECT DISTINCT party_id
- INTO #partyids
- FROM tge_games
- -- ADD table with all platform type
- SELECT DISTINCT platform_type
- INTO #platform_type
- FROM tge_games_operators
- -- Create table with cross party id and platform type
- SELECT *
- INTO #partandplat
- FROM #platform_type
- CROSS JOIN #partyids
- -- data to be inserted for disable all party ids for all platform for list of operators
- SELECT *
- INTO #fulltable
- FROM (SELECT to_operators.operator_id AS OPERATOR_ID,
- -1 AS GAME_ID,
- TP.*
- FROM to_operators,
- (SELECT *
- FROM #partandplat) AS TP
- WHERE operator_id IN ( 1, 2, 3, 12,
- 21, 20 )) AS TT
- -- create a cursor to delete from TGE_Games operators if key already exists
- DECLARE @DeleteExistKeysCursors AS CURSOR
- DECLARE @Game_ID INT
- DECLARE @Operator_ID INT
- DECLARE @Party_ID INT
- DECLARE @Platform_Type NCHAR(10)
- SET @DeleteExistKeysCursors = CURSOR
- FOR SELECT *
- FROM #fulltable
- ---------------------
- OPEN @DeleteExistKeysCursors
- FETCH next FROM @DeleteExistKeysCursors --Start the cursor
- INTO @Operator_ID, @Game_ID, @Platform_Type, @Party_ID
- WHILE @@FETCH_STATUS = 0 --while there is a loaded record, keep processing
- BEGIN
- DELETE FROM tge_games_operators
- WHERE operator_id = @Operator_ID
- AND game_id = @Game_ID
- AND platform_type = @Platform_Type
- AND @Party_ID = party_id
- FETCH next FROM @DeleteExistKeysCursors --Start the cursor
- INTO @Operator_ID, @Game_ID, @Platform_Type, @Party_ID
- END
- CLOSE @DeleteExistKeysCursors
- INSERT INTO tge_games_operators
- SELECT *
- FROM #fulltable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement