August 13, 2008 at 8:31 pm
I think its gonna be BCP week for me. 😉
The text file i am loading is containing few columns with datetime dataype. In order to load this file into final table, i have to match the datetime format and convert it on the fly while loading data.
The date format in file is dd/mm/yy hh:mm where as my sql server table dateformat is yyyy-mm-dd hh:mm
I have already followed an approach to load the data in temporary table with varchar datatype and then write the sql with convert functions to load data into final table.
Is there any better way through which i could load the data, convert it on the fly using BCP
August 14, 2008 at 3:07 am
BULK INSERT worked for me. My test file contains a single column - date values formatted like "01/08/08 03:10" (dd/mm/yy hh:mm) which I imported in a table with a smalldatetime colmn.
BULK INSERT test..test1
FROM 'C:\testdt.txt'
WITH
(
FIELDTERMINATOR ='\t',
ROWTERMINATOR =''
)
...sorry for the "wink" that appears instead of "newline"...
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply