Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Identify Events with No Steps
- SELECT *
- FROM core_profile P
- LEFT JOIN [evnt_event_step] ON P.profile_id = evnt_event_step.profile_id
- WHERE
- event_step_id is null
- AND P.profile_type = 4
- DECLARE @ProfileWithSteps INT = ;
- DECLARE @ProfileWithNoSteps INT = ;
- DECLARE @ProfileWithNoStepsName VARCHAR(100) = (SELECT P.profile_name from core_profile P where P.profile_id = @ProfileWithNoSteps)
- -- Copy steps from @ProfileWithSteps into @ProfileWithNoSteps
- IF NOT EXISTS (SELECT TOP 1 S.event_step_id FROM evnt_event_step S WHERE S.profile_id = @ProfileWithNoSteps)
- BEGIN
- INSERT INTO evnt_event_step
- SELECT evnt_event_step.module_id,@ProfileWithNoSteps, evnt_event_step.step_order
- FROM evnt_event_step
- WHERE evnt_event_step.profile_id = @ProfileWithSteps
- END
- ELSE
- BEGIN
- PRINT 'UNABLE TO COPY Steps to ' + @ProfileWithNoStepsName + ' already has steps'
- END
- -- Copy step settings from @ProfileWithSteps into @ProfileWithNoSteps
- IF NOT EXISTS
- (SELECT TOP 1 * FROM evnt_event_step S
- JOIN evnt_event_step_setting SS on S.event_step_id = SS.event_step_id
- WHERE S.profile_id = @ProfileWithNoSteps)
- BEGIN
- INSERT INTO evnt_event_step_setting
- SELECT (SELECT event_step_id from evnt_event_step where step_order = S.step_order AND profile_id = @ProfileWithNoSteps)
- ,SS.name, SS.value,SS.type_id
- FROM evnt_event_step S
- JOIN evnt_event_step_setting SS on S.event_step_id = SS.event_step_id
- WHERE S.profile_id = @ProfileWithSteps
- END
- ELSE
- BEGIN
- PRINT 'UNABLE TO COPY Step Settings to ' + @ProfileWithNoStepsName + ' already has step settings'
- END
- -- Re-examine Events with No Steps
- SELECT *
- FROM core_profile P
- LEFT JOIN [evnt_event_step] ON P.profile_id = evnt_event_step.profile_id
- WHERE
- event_step_id is null
- AND P.profile_type = 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement