Friday, March 9, 2012

how to import a text file in sql express 2005

I didn't find any option of IMPORT to import a TEXT FILE in sql express 2005.

Check out the OPENROWSET with the BULK option statement.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||Check also the BCP command if you want to do it from the commandline.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||If you are still looking for an answer, the following worked for me:

BULK INSERT music.dbo.song
FROM 'c:/songs.csv' WITH (FIELDTERMINATOR = ',',MAXERRORS=1000)
GO

of course replace the music.dbo.song with your table name and the FROM 'c:/songs.csv' with your filename|||

Thanks it works.

Can u just tell me one more thing.

if the fieldterminator is a tab then how to represent it.

and

if the text file depend upon no. of character then how to saperate it

for eg.

user name of 30 character & password of 10 character then text file contain password exactly after 30 character/spaces.

|||

how to do so.

can u explain

No comments:

Post a Comment