Showing posts with label spaces. Show all posts
Showing posts with label spaces. Show all posts

Tuesday, March 27, 2012

export data without trailing spaces

Hello,
when I export data from a table to a text file, I get trailing spaces
if the data type in char. (This dosen't happen if the data type is
varchar). I can get rid of the spaces by using the trim() function on
every signle column. here is an example:
DTSDestination("first_name") = DTSSource("last_name")

My question is:
Is there any easier way to get ride of the training spaces for all
columns when exporing a table? It is too time consuming if I have to
type trim() for every single column in the table.
Thank you in advance,
EddyHi

You can create a trim string transformation for the columns you wish to
trim. Depending on what currently have you may have to remove them from the
current transformation and create a new one.

John

<eddiekwang@.hotmail.com> wrote in message
news:1103225990.307403.256040@.c13g2000cwb.googlegr oups.com...
> Hello,
> when I export data from a table to a text file, I get trailing spaces
> if the data type in char. (This dosen't happen if the data type is
> varchar). I can get rid of the spaces by using the trim() function on
> every signle column. here is an example:
> DTSDestination("first_name") = DTSSource("last_name")
> My question is:
> Is there any easier way to get ride of the training spaces for all
> columns when exporing a table? It is too time consuming if I have to
> type trim() for every single column in the table.
> Thank you in advance,
> Eddy

Monday, March 26, 2012

Export Data in a specific format

I have a transaction table that I need to export for our financial system to import. It has a lot of zero's and a lot of spaces in the requested file.

Is there a way to do that and if there is how?

Can someone please help me in explaining how to extract data to a txt file as well. Here is my SQL statement thus far:

SELECT AccountNumber, CustomerID, Sum(CheckTotal) As CKT, Sum(PSD.Quantity) as QTY, Sum(ItemPrice * PSD.Quantity) As ItPrice, Sum(FCharge) as FCharge, Sum(SCharge) as SCharge, Sum((ItemPrice * PSD.Quantity) + FrankingCharge + ServiceCharge) As Total From PSD INNER JOIN Customer ON PSD.CustomerId = Customer.ID INNER JOIN Item ON PSD.ItemId = Item.ID Where PSD.Datecreated Between '12/01/2006 01:00:00 AM' and '12/31/2006 11:00:00 AM' Group By AccountNumber

ThanksWhat language are you using to do this?|||If you don't need to incorporate the export/import functionality in application - use Data Transformation Services (DTS).|||Guys,

I was away for the holiday, Sorry.

The language I am using is VB.

I am not familiar with DTS. Can you explain how that works please.

Thanks!!|||See here: data transformation services|||create a view (based on your query + include some more where condition to eliminate zeros & spaces) and then directly insert it to the new table.

like,

insert into ...(finance. table)
select ...
from (new view)|||use OSQL command line utility to get all the result in a txt file.

open command prompt and type OSQL /? for more options|||That sounds great, but as I am new to VB I might need some help on how to call that through vb. Any Ideas?