Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two quick questions

Status
Not open for further replies.

drublic1019

IS-IT--Management
Sep 28, 2005
46
US
I have a table that I want to export to a flat file. The problem I am running into is the person I am sending it to needs it in a specific format. It is a comma serperated file and I need quotes on some of the data but not all.

For example : "1234",abc,"id"

I know how to make it all or none but not conditionally. Also I have some fields that the total in them is 0.00 and when this gets exported to the file the format become .00, is there a way to make it 0 with out changing the ones that have totals. Thanks.
 
Second question first: What format / datatype is the 0.00 in before it gets exported and what format / datatype are you specifying for the CSV file?

First Question: Create a global temp table (##<name>) in the package and pull your data into there first. Then add an Execute SQL Task which updates the table on the columns you want in quotes by concatenating the value with the quotes.

Code:
Update MyTable
Set Col1 = '"' + Col1 + '"'

Then pull the data out of the temp table like you were pulling it out of the original table and export it to the file in question.

Does that help?



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
You could create a view that formats the ouput as needed and then use the view as your data source.

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
thanks for the advise. I used your advise catadmin and created the temp table. It worked great.
 
Glad I could help. @=)

Did you get the 0.00 thing to work too or is that still a problem for you?



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
I got that taken care of with a rtrim active script. One again thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top