Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 SQL Query of rpackage
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Oliviaf2012
Starting Member

16 Posts

Posted - 09/26/2012 :  06:16:22  Show Profile  Reply with Quote
Hi
I am runnnig a query as follows :

SELECT count(distinct(address2_fax)) As IE from AllActiveAuthorised
WHERE [Country Code] = ('IE')
AND allowmail = 'Allow'
and statuscode = '1'
AND l2g_brandname = 'Viviscal Max' AND
l2g_dispatcheddate >= CONVERT(DATETIME, '2012-09-01 00:00:00', 102)
AND l2g_dispatcheddate <= CONVERT(DATETIME, '2012-10-01 00:00:00', 102)

and I want to run this for a number of countries and display all the results together - this works ok in Management Studio as all results are shown one after the other but in SSIS I want the results output to a csv file.

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/26/2012 :  06:54:33  Show Profile  Reply with Quote
If you remove the WHERE condition on country code and group by country code, it should return data all the countries. You may want to order the results by country code so you can easily look up countries in the CSV file.
SELECT [Country Code],
       COUNT(DISTINCT(address2_fax)) AS [Count]
FROM   AllActiveAuthorised
WHERE  allowmail = 'Allow'
       AND statuscode = '1'
       AND l2g_brandname = 'Viviscal Max'
       AND l2g_dispatcheddate >= CONVERT(DATETIME, '2012-09-01 00:00:00', 102)
       AND l2g_dispatcheddate <= CONVERT(DATETIME, '2012-10-01 00:00:00', 102)
GROUP BY
       [Country Code]
ORDER BY
       [Country Code];
Go to Top of Page

Oliviaf2012
Starting Member

16 Posts

Posted - 09/26/2012 :  07:11:54  Show Profile  Reply with Quote
Fantastic
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000