dbTalk Databases Forums  

Fetching Data from 2 tables and send in text File using query

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss Fetching Data from 2 tables and send in text File using query in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chintu4uin@gmail.com
 
Posts: n/a

Default Fetching Data from 2 tables and send in text File using query - 12-08-2009 , 12:50 AM






Hi friends need help for the following
I m using SQL 2000
What I want to do is I want to create a single Text File containg
data from 2 tables using DTS.
Basically my First Table is having 10 columns and second table is
having 40 columns so my text file will be generating of 50 columns in
that what I want to do is If suppose my first table has 5 rows and
second table has 20 rows so final text file will be having 25 rows in
all.
Now in text file first five rows should be of Table A which has 10
columns so from 11th column ownward it will have all null data.From
6th row ownward my second table is having data so in that case 1-10
columns will have null data and from 11th coulmn Table B data will be
there now I want to form a query in such a way that my result set
should be as mention above.

Sample
Table A
-------------------
Col A1 | Col A2 | Col A3
1 XYZ 10
2 MNO 20

Table B
-------------------
Col B1 | Col B2 | Col B3 | Col B4
1 x m 10
2 y n 20

Query Resultset
-------------------
Col A1 | Col A2 | Col A3 | Col B1 | Col B2 | Col B3 | Col B4
1 XYZ 10 null null null
null
2 MNO 20 null null null
null
null null null 1 x
m 10
null null null 2 y
n 20

So I will send this query in DTS to generate a Text file as shown in
resultset.
Please friend any one can suggest something..
Irrespective of relation I want to fetch data from both table and form
File so what can be the query to do so.

Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: Fetching Data from 2 tables and send in text File using query - 12-08-2009 , 01:56 AM






On Mon, 7 Dec 2009 22:50:27 -0800 (PST), chintu4uin (AT) gmail (DOT) com wrote:

(snip)

Replied in comp.databases.ms-sqlserver.

Please don't post the same question to multiple newsgroups.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.