Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DTS to export a multiple SELECT statement to a file

Status
Not open for further replies.

rzirpolo

Programmer
Apr 8, 2002
163
GB
I have created a SQL statement in Query Analyzer which is 3 seperate SELECT statements querying 3 different tables (I cannot include it all in one statement due to ambigious column headings). Upon running this in Query Analyzer it shows 3 sets of results in the grid. I now want to set this up in DTS so that a daily export can be put out to a spreadsheet.

The problem I am having is that it only recognises the first SELECT statement and outputs this data to the spreadsheet. Is there anyway to configure DTS so it will recognise the 3 seperate statements and put them in the .csv export.

Also tied in with this query.... how do I configure DTS so that if a column is NULL it will show the whole row regardless. I am finding that rows I have grouped that have have a NULL value present do not display.
 
You can get around "I cannot include it all in one statement due to ambigious column headings" by aliasing your tables and then prefix the ambigous columns w/ the alias table name. An example may look like ...

SELECT A.Address, B.Address, A.Phone, B.Phone
FROM TableA as A
JOIN TableB as B
WHERE A.ID = B.ID

Thanks

J. Kusch
 
I know SQL well and know how to do this, I just wondered if there was a way round it.

Me just being lazy ha ha !!!

Cheers
 
I'm certainly no expert, but do you have a GO statement between the SELECT clauses? I believe in DTS that is necessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top