I have a requirement to export data from a sql server table to a flat file. I need to format data for some columns during the export.
Can you please advise as to how I need to accomplish this?
The definition of table is:
CREATE TABLE [dbo].[test](
[Test1] [bigint] IDENTITY(1,1) NOT NULL,
[PARENT_MCIID] [bigint] NULL,
[CREATION_TIME] [datetime] NOT NULL,
[TERMINATION_TIME] [datetime] NOT NULL,
[AB_CREATION_TIME] [datetime] NOT NULL,
[AB_TERMINATION_TIME] [datetime] NOT NULL,
[READY_FOR_DELETE] [smallint] NOT NULL,
[TRANSFER_SOURCE] [bigint] NULL,
[AB_SCHEDULED_PICKUP_TIME]
[M_SCHEDULED_DROP_OFF_TIME
[TZ_SCHEDULED_DROP_OFF_TIM
[AB_SCHEDULED_DROP_OFF_TIM
[M_INITIAL_ODOMETER_READIN
[M_FINAL_ODOMETER_READING]
[M_TOTAL] [varchar(50)] NULL,
[M_DISPATCH_TIME] [datetime] NULL,
[TZ_DISPATCH_TIME] [bigint] NULL,
[AB_DISPATCH_TIME] [datetime] NULL,
[T1_DRIVER_RESPONSE_TIME]
[datetime] NULL,
[T2_DRIVER_RESPONSE_TIME] [bigint] NULL,
[LE_LMSNSPRCSSTRMNTNTRG] [bigint] NULL,
[LE_LIMOUSINE_SERVICNDD] [bigint] NULL,
PRIMARY KEY CLUSTERED
(
[Test1] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS =
ON) ON [PRIMARY]
) ON [PRIMARY]
GO
The columns with datetime format should be as below. For example the value should be 08/23/2012 14:56:10:365046
after it's exported to text file. If the milliseconds has less than 6 digits, it should be zero filled out to 6 digits. If the milliseconds is more than 6 digits, then it should be trimmed down to fit. And currently, for example, the value in sql
server table is 08/23/2012 14:56:10:365
The columns with nvarchar data type should be surrounded by double quotes to define the beginning and end of a value in the text file. Ex:
"abcde" .
Thanks.