I am trying to use a Data Flow Task to export a SQL query result into csv file. It’s a very simple SQL. The column PTLASTUPDATEDDTTM is a DATETIME type. My SQL have to convert its format:
select rtrim([PTADDRESSIDPK]) as [PTADDRESSIDPK],
rtrim([PTADDRLINKIDPK]) as [PTADDRLINKIDPK],
rtrim( [PTPOSTALCODE]) as [PTPOSTALCODE],
rtrim( convert(varchar, [PTLASTUPDATEDDTTM], 105) + ' '+ convert(varchar, getdate(), 108) ) as [PTLASTUPDATEDDTTM],
rtrim( [PTPerson]) as [PTPerson] from Table_A
But after I put it into the SQL source. And set destination as Flat File, its column mapping messed up. The [PTLASTUPDATEDDTTM] become 1st column in the destination. How can I change this column back to its original position (the same position as the SQL query)? And my SQL used rtrim() because if I don’t use it, the csv (use vertical bar | as column delimiter) will have spaces in each column. Is there any other way to get rid of redundant spaces in each column?
1
I found the issue. I used an existing csv as destination file. Then the order of columns are decided by that old existing csv.