Wednesday, March 28, 2012

Importing Text Files

hi friends ,

Thank you for the help and support you have given me. Now i am confronted with a new problem. I have to import some textfiles to SQL Server Tables .The columns in textfile is seperated with pipe"|" . I f any body knows this please help me .

Thanks $ Regards

Nevin

You can use BULK INSERT

Code Snippet

BULK INSERT [DatabaseName].dbo.[Table Name]
FROM '<Your CSV File>'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '|\n'
)

|||

You have to use Like this

CREATE TABLE F(A VARCHAR(MAX))

BULK INSERT [learner].dbo.[F]

FROM 'E:\SHARE\TE.TXT'

WITH

(

FIELDTERMINATOR = '|',

ROWTERMINATOR = '|\n'

)

SELECT * FROM F

|||

thank you very much Krupa Sankar . very useful to me it works fine

|||

Thank you very much .It works fine

No comments:

Post a Comment