[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL 2008 Output to Text File

Posted on 2011-03-02
6
Medium Priority
?
652 Views
Last Modified: 2012-05-11
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
Comment
Question by:amickfarms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 15

Expert Comment

by:derekkromm
ID: 35017732
0
 

Author Comment

by:amickfarms
ID: 35017774
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
 
LVL 15

Expert Comment

by:derekkromm
ID: 35017793
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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:amickfarms
ID: 35017805
That may work.  I will work with this for a while and see what I can come up with.
0
 
LVL 15

Accepted Solution

by:
derekkromm earned 1000 total points
ID: 35017827
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
 

Author Closing Comment

by:amickfarms
ID: 35483357
I had to use oterh SQL functions to make this work.  Still not finished with the project.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question