dbTalk Databases Forums  

SQL 2008 Export to CSV. Numeric Fields quoted. WHY?

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss SQL 2008 Export to CSV. Numeric Fields quoted. WHY? in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JOHN KEANE
 
Posts: n/a

Default SQL 2008 Export to CSV. Numeric Fields quoted. WHY? - 11-19-2008 , 07:47 AM







I created a test table to demonstrate my problem.

CREATE TABLE [dbo].[TestExport](
[F1] [char](5) NOT NULL,
[F2] [decimal](9, 0) NOT NULL,
[F3] [decimal](5, 2) NOT NULL,
[F4] [decimal](6, 2) NOT NULL,
[F5] [numeric] (9, 0) NOT NULL)
Insert into testexport select 'REC1', 1, 1, 1, 1
Insert into testexport select 'REC2', 2, 2, 2, 2
Insert into testexport select 'REC3', 3, 3, 3, 3
Insert into testexport select 'REC4', 4, 4, 4, 4
Insert into testexport select 'REC5', 5, 5, 5, 5

select * from testexport

Using SQL Server 2008, I click on the database, then Tasks, then export data
to start the SQL Server Import and Export Wizard.

I use the default "SQL Server Native Client 10.0: to access the source
database and select "Flat File Destination" for the output.
I give the output file a "csv" extension, format="delimited", text qualifier
= " (I enter a double quote in the field) and ask for the column names to be
in the first row.

Row delimiter is "{CR}{LF}" and column delimiiter is "Comma {,}"

The following is displayed:
Click Finish to perform the following actions:


Source Location : WDSAPPS07
Source Provider : SQLNCLI10

Copy rows from [dbo].[TestExport] to d:\temp\test.csv
The new target table will be created.

The package will not be saved.
The package will be run immediately.

Provider mapping file : C:\Program Files\Microsoft SQL
Server\100\DTS\MappingFiles\MSSQLToSSIS10.XML

The output files content is:

"F1","F2","F3","F4","F5"
"REC1 ","1","1.00","1.00","1"
"REC2 ","2","2.00","2.00","2"
"REC3 ","3","3.00","3.00","3"
"REC4 ","4","4.00","4.00","4"
"REC5 ","5","5.00","5.00","5"

Why do the numeric fields have quotes around them?

JK



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.