SQL 2008 Output to Text File

I have sql 2008 r2 and am needing to create a text file from a query result.  The data will need to be in certain row,character locations in the the text fields as it will be used to import into an existing system.  Can someone point me a direction of what sql commands to use?  I eventually would configure it as a stored procedure to run on a fixed interval of time.
amickfarmsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
derekkrommConnect With a Mentor Commented:
Ya, you can do some simple comparisons on that in SSMS by changing your output type to Text and doing something like

"select a,b,c from tbl"
"select convert(char(10),a), convert(char(20),b),convert(char(10),c) from tbl"

and seeing the differing displays
0
 
amickfarmsAuthor Commented:
That really doesn't give me the results I was aiming for.  I need to place data in certain row,character locations in the text file.  A little more than just dropping to a text file.
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
derekkrommCommented:
i'm not sure what you're looking for then

you want it to be formatted a specific way? if so, you may want to look at using char/nchar data types instead of varchar/nvarchar

those will be padded with spaces at the end, so if you want your file to look like

COLA.....COLB......etc
COA.......COB.......etc

char will pad the necessary # of spaces

not sure if that helps?
0
 
amickfarmsAuthor Commented:
That may work.  I will work with this for a while and see what I can come up with.
0
 
amickfarmsAuthor Commented:
I had to use oterh SQL functions to make this work.  Still not finished with the project.
0
All Courses

From novice to tech pro — start learning today.