Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqln00b9
Starting Member
8 Posts |
Posted - 2012-06-24 : 02:47:12
|
| Hello,I am using SQL 2008. I have two tables connected by a foreign key.One has 15 columns, the other 300 columns.Almost every month we will now need to export the data in a flat text file to a 3rd party that wants delivery in a single flat file . Is there a way to output all columns (from both tables) into a single text file using the foreign key connection...or do I need to join these two tables together and then export (that would be a pain)? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-24 : 10:08:31
|
| yep you need to join the tables on foreign key,primary key column to get all the columns from them before you export to flat file.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2012-06-24 : 10:24:06
|
| It's relatively easy to do this. It you try the import/export wizard, you'll see you can write a query for your join and output the data in a variety of ways...csv or excel for example. |
 |
|
|
sqln00b9
Starting Member
8 Posts |
Posted - 2012-06-24 : 11:34:25
|
| flambaster, at what point do i have option to enter my own query in the wizard? the only place i see a query in export to text file is in the preview...but i cannot seem to edit that |
 |
|
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2012-06-24 : 12:08:01
|
| Yes, you should...So we're on the same page, these are the steps I'm following:1. In your object list, under the DB from which you want to export data, right click2. Select Tasks3. Select Export Data4. Set your Data Source, Server Name, Authentication Method and Database (data TO export)5. Set your Destination 6. Specify Table Copy or Query...Two radio buttons, first is "Copy", select the 2nd "Write a Query..." You can specify your query in the next dialogue box that will pop up. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-24 : 14:13:11
|
| Almost every month we will now need to export the data in a flat text filefor that part you can save the wizard as a ssis package and call it from sql job to get it executed automatically as a job------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|