• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 662
  • Last Modified:

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.
0
amickfarms
Asked:
amickfarms
  • 3
  • 3
1 Solution
 
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
 
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
amickfarmsAuthor Commented:
That may work.  I will work with this for a while and see what I can come up with.
0
 
derekkrommCommented:
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:
I had to use oterh SQL functions to make this work.  Still not finished with the project.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now