Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Why is there a Comma being input in the TXT output file?

Posted on 2012-03-19
6
Medium Priority
?
353 Views
Last Modified: 2012-03-19
I've created a DTSx Package that runs the following Query:

SELECT '00000123456789002'+RIGHT ('00000000' + LTRIM(CAST(CHECKNO AS VARCHAR(20))), 15)
+ CONVERT(varchar(10),CHECKDT, 112)+ RIGHT ('0000000' + REPLACE (CAST(checknet AS VARCHAR(20)), '.',  ''), 10)+CASE(ckstatus)
WHEN 'O' THEN '' WHEN 'V' THEN 'C' END + '' as Val
FROM dbo.CHK

WHERE checkdate BETWEEN '03/14/12' and '03/14/12' and bankid='MYBANK'and ISNUMERIC(checkno)=1

The Results are put into a Txt File

At the end of the results it's adding a ,
000001234567890020000000020201203140000058878C,

Can anyone tell me why this is happening and how I can fix it?
0
Comment
Question by:Rmumpower00
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:lcohan
ID: 37739690
Perhaps it is a CSV text that you selected in the SSIS package.
You could manually try to export something like :

exec master..xp_cmdshell N'sqlcmd -E -Q"set nocount on; SELECT ''00000123456789002''+RIGHT (''00000000'' + LTRIM(CAST(CHECKNO AS VARCHAR(20))), 15) + CONVERT(varchar(10),CHECKDT, 112)+ RIGHT (''0000000'' + REPLACE (CAST(checknet AS VARCHAR(20)), ''.'',  ''''), 10)+CASE(ckstatus) WHEN ''O'' THEN '''' WHEN ''V'' THEN ''C'' END + '''' as Val
FROM dbo.CHK
WHERE checkdate BETWEEN ''03/14/12'' and ''03/14/12'' and bankid=''MYBANK''and ISNUMERIC(checkno)=1;" -W -o"c:\output.txt"'
0
 

Author Comment

by:Rmumpower00
ID: 37739740
So if I ran that query it would export it to a Text?
0
 
LVL 11

Accepted Solution

by:
Simone B earned 2000 total points
ID: 37739758
If it's showing up only at the end of a row, then it could be the Row Delimiter. Edit your flat file connection, then select Columns. You should see a Row Delimiter and a Column Delimiter. If it's using Comma {,} then change it to {CR}{LF}. That will use the 'carriage return' or 'line feed' for the line break, instead of a comma.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Rmumpower00
ID: 37739760
I'll do that now Buttercup, I think you're dead on!
0
 

Author Closing Comment

by:Rmumpower00
ID: 37739774
That was it, Thanks a ton!
0
 
LVL 11

Expert Comment

by:Simone B
ID: 37739777
Excellent! Happy to help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

972 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