Soldato
- Joined
- 18 Oct 2002
- Posts
- 16,052
- Location
- The land of milk & beans
Hi All,
I've got a SQL statement which exports a mailing list which is generated via classic ASP. I'd like to switch this to a stored procedure for obvious reasons.
The SQL statement is...
The bit in the loop is generated by running a separate query in ASP which finds all custom fields for the mailing list.
Would it be possible to replicate this loop in SQL?
I've tried to keep this as simple as possible so I've not posted the table structure, let me know if it'd make more sense if i posted that too.
I've got a SQL statement which exports a mailing list which is generated via classic ASP. I'd like to switch this to a stored procedure for obvious reasons.
The SQL statement is...
Code:
SELECT EmailAddress, OptInConfirmedDate, UnsubscribedDate,
-- \/ \/ This bit is generated by an ASP loop
(SELECT TOP 1 CustomValue FROM MailingList_Import_Values WHERE CustomFieldID = 1 AND MailingListMemberID = MailingList_Members.MailingListMemberID ORDER BY DateAdded DESC) AS [Firstname],
(SELECT TOP 1 CustomValue FROM MailingList_Import_Values WHERE CustomFieldID = 2 AND MailingListMemberID = MailingList_Members.MailingListMemberID ORDER BY DateAdded DESC) AS [Surname]
-- /\ /\ This bit is generated by an ASP loop
FROM MailingList_Members WHERE MailingListID = 1AND ((OptInConfirmed = 1) OR (IsUnsubscribed = 1)) ORDER BY EmailAddress
The bit in the loop is generated by running a separate query in ASP which finds all custom fields for the mailing list.
Would it be possible to replicate this loop in SQL?
I've tried to keep this as simple as possible so I've not posted the table structure, let me know if it'd make more sense if i posted that too.