Friday, February 24, 2012

import a CSV delimited text file into a table

Hi,

Could you help me to write a script to import a CSV delimited text file into a sql server table.?

Thanks,

carlos

Hi,

you can use either a linked server or OPENQUERY for ahhoc querying the data, or the Import wizard of Management Studio. A sample of this would be:

http://p2p.wrox.com/topic.asp?TOPIC_ID=20163

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Thanks Jens, but it is too complex.

I am using BULK INSERT, but now I have a problem when a try to load a DATE value, I get error

Msg 4864, Level 16, State 1, Line 2

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 4 (EffectiveDate).

The script is

BULK INSERT grouppolicy

FROM 'C:\datatoload\test.txt'

WITH (

FIELDTERMINATOR = '\t',

ROWTERMINATOR = '\n'

)

Can Somebody help me

Thanks,

No comments:

Post a Comment