All pastes #410770 Raw Edit

Someone

public sql v1 · immutable
#410770 ·published 2007-03-26 17:23 UTC
rendered paste body
			INSERT INTO @Consumer_Email (Consumer_ID, Email_NID)			SELECT DISTINCT				e.Consumer_ID,				e.NID			FROM Consumer_Email e				INNER JOIN Consumer c ON c.id = e.Consumer_ID			WHERE Email_Address = @Email				AND c.DoNotEmail IS NULL  -- if this consumer has DoNotEmail Set then don't add any subscriptions				AND @DoNotEmail IS NULL  -- if @DoNotEmail was passed in with a date then don't add any subscriptions			SET @c = (SELECT MIN(NID) FROM @Consumer_Email)			SET @MAX_Email_NID = (SELECT MAX(NID) FROM @Consumer_Email)			WHILE @c <= @MAX_Email_NID			BEGIN				SELECT 					@oConsumer_ID = Consumer_ID,					@oEmail_NID = Email_NID				FROM @Consumer_Email				WHERE NID = @c				-- adding flag to comply with email preference -- indra 3/12/2007				EXECUTE dbo.Resolve_SubscriptionText_AddOnly @Consumer_ID = @oConsumer_ID, @Address_NID = NULL, @Email_NID = @oEmail_NID, @SubscriptionText = @SubscriptionStr, @iReturn = @iReturned OUTPUT, @sReturn = @sReturned OUTPUT, @Check_And_Update_DoNotEmail = @Check_And_Update_DoNotEmail				SET @c = @c + 1						END