Having trouble exporting data from sql table to a text file

I am trying to export data from a sql table into a text file.  I am using fixed width, but it puts all the records on 1 line, how would I get it to do one line per record?  I am using the import export wizard.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


See my answer's picture at this comment :


I hope this help you!!
Happy New Y.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CeleritasPrimeAuthor Commented:
The actual export works, but after I export the file to text, I run and executable file that picks up the text file and imports the data into 2 tables in another database.  This isn't working because it is picking up the carriage return symbols as part of the data, and I am getting an error saying the record is invalid.  Also I notice that the export is put extra 15 extra spaces in my file, which is another thing that is throwing my fixed width off.
CeleritasPrimeAuthor Commented:
also here is a copy of the query that I am using to generate that data for the text file, and spacing is very essential.

                      (RTrim(affiliateid) + Space(15-Len(dbo.TRIM(affiliateid))) + SPACE(2)
                      + RTrim(fedid) + Space(10-Len(dbo.TRIM(fedid))) + 'C' + Space(15) +
                       '1060' + Space(5) + 'Y' + Space(6) + '01/01/2005' + dbo.Trim('12/31/2400') + Space(28) + dbo.trim('00') +
                       Space(60) + RTrim(fullname) + Space(60-Len(dbo.TRIM(fullname))) +
                       Space(28)+'0000000000000000000' + SPACE(1)+ '100.00' + Space(92) + 'R' + 'Y' + RTrim(phystate) +
                       RTrim(phyzip) + Space(10-Len(dbo.TRIM(phyzip))) + Space(2) +
                        RTrim( (CASE WHEN attributeid = 'TMSC000834493' THEN thevalue END)) +
                        Space(60-Len(dbo.TRIM((CASE WHEN attributeid = 'TMSC000834493' THEN thevalue END)))) + Space(60) +
                         RTrim(phyaddr1) + Space(60-Len(dbo.TRIM(phyaddr1))) +
                         RTrim(phyaddr2) + Space(60-Len(dbo.TRIM(phyaddr2))) +
                          Space(60) + RTrim(phycity) + Space(20-Len(dbo.TRIM(phycity))) +
                          RTrim(phone) + Space(25-Len(dbo.TRIM(phone)))+ SPACE(1677)) as Report
FROM         dbo.dbo_entity INNER JOIN
                      dbo.dbo_provider ON dbo.dbo_entity.entid = dbo.dbo_provider.entityid INNER JOIN
                      dbo.dbo_providerattribute ON dbo.dbo_provider.provid = dbo.dbo_providerattribute.provid INNER JOIN
                      dbo.dbo_affiliation ON dbo.dbo_provider.provid = dbo.dbo_affiliation.affiliateid
WHERE     (dbo.dbo_entity.enttype = N'PROVIDER')
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.