Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to read Tab delimited file in sql server 2005

Author  Topic 

ksandy
Starting Member

3 Posts

Posted - 2011-04-04 : 08:05:40
How to read Tab delimited file in sql server 2005
This file is generated using BCP command, and I now want to read it in sql server 2005. Could any body help me.

asgast
Posting Yak Master

149 Posts

Posted - 2011-04-04 : 08:23:57
you can use bulk insert command to move the data into a table, but the table structure needs to be the same as file structure. The same number of columns and the same data type.
BULK INSERT #table
FROM 'c:\temp\file.txt'
Go to Top of Page

ksandy
Starting Member

3 Posts

Posted - 2011-04-04 : 10:16:18
Hi,

Thanks for your reply, but it is reading only the headers not the data, and my file is .xls with header.
Thanks in advance
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-04-04 : 11:01:39
Can use SSIS or Data Import Wizard then.
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-04-04 : 11:54:58
Right click on your desired database --> Tasks--->Import Data, here select "Flat File Source" anda Data Source and now browse your file, provide delimiter of your choice... and done

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

ksandy
Starting Member

3 Posts

Posted - 2011-04-06 : 07:21:02
Thanks it worked out. Thank you very much

quote:
Originally posted by asgast

you can use bulk insert command to move the data into a table, but the table structure needs to be the same as file structure. The same number of columns and the same data type.
BULK INSERT #table
FROM 'c:\temp\file.txt'

Go to Top of Page
   

- Advertisement -