SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need a batch process solution (Non-SSIS if possible)


Need a batch process solution (Non-SSIS if possible)

Author
Message
SQL_ME_RICH
SQL_ME_RICH
SSC Eights!
SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)

Group: General Forum Members
Points: 932 Visits: 1596
Hello...

I have the following query which returns information to me on whether a user has gone from just being a user to a customer in our system. Here's the SQL:

SELECT     AM_invoiceheader.BuyerID, COUNT(DISTINCT AM_invoiceitems.InvoiceID) AS Invoices, SUM(AM_invoiceitems.SalePrice) AS Revenue, 
YEAR(AM_invoiceheader.ShipDate) AS Year, SUM(AM_invoiceitems.Quantity) AS Units, AM_buyers.BillToEmail, AM_buyers.ShipToEmail
FROM AM_invoiceheader INNER JOIN
AM_invoiceitems ON AM_invoiceheader.InvoiceID = AM_invoiceitems.InvoiceID INNER JOIN
AM_buyers ON AM_invoiceheader.BuyerID = AM_buyers.BuyerID
WHERE (AM_invoiceitems.Typeid IN (1)) AND (AM_invoiceheader.InvoiceSourceID IN (5, 6)) OR
(AM_invoiceitems.Typeid IN (1)) AND (AM_invoiceheader.InvoiceSourceID IN (5, 6))
GROUP BY AM_invoiceheader.BuyerID, YEAR(AM_invoiceheader.ShipDate), AM_buyers.BillToEmail, AM_buyers.ShipToEmail
HAVING (AM_buyers.BillToEmail LIKE N'user@gmail.com') OR
(AM_buyers.ShipToEmail LIKE N'user@embarqmail.com')
ORDER BY AM_invoiceheader.BuyerID



I have 17k of email addresses that I need to run through this query, and I am hoping there is a way for me to be able to do this in just a T-SQL query by way of a SQL Agent Job or some other batch process (other than SSIS - long story for why I am avoiding that method).

Please let me know if you need additional information from me to help out, and any and all help is definitely appreciated!

Thank you in advance...

SQL_ME_RICH
tim.hansen
tim.hansen
SSC-Enthusiastic
SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)

Group: General Forum Members
Points: 188 Visits: 343
Are the 17k of email addresses in a table?


Living in Paradise: N 34°16'07.99" W 119°12'17.58"
SQL_ME_RICH
SQL_ME_RICH
SSC Eights!
SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)SSC Eights! (932 reputation)

Group: General Forum Members
Points: 932 Visits: 1596
Good question...No, they are in an .xlsx file that I can convert as needed (if needed). Also - and sorry I forgot to include this initially, but I want to save the result set for each of the addresses (Either in a temp table or if there is an easier way to output them to say an .csv/.xls file, I am open to that as well).

Thanks again
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search