Friday, February 24, 2012

import a text file without commas to an sql table

how i can import a text file without commas to an sql table, knowing the
subject of every clomn in the text file (col 1 to col 8- name, col 9 to col
15 - address e.c.)?If you are using DTS, you have to specify the file type as 'fixed width',
and then DTS lets you specify the position of each column. When using BULK
INSERT, you'll have to create a format file that describes the columns.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Sam" <focus10@.zahav.net.il> wrote in message
news:%23vvM3nejFHA.1372@.TK2MSFTNGP10.phx.gbl...
how i can import a text file without commas to an sql table, knowing the
subject of every clomn in the text file (col 1 to col 8- name, col 9 to col
15 - address e.c.)?|||Are you using some other delimiter instead of commas? BCP and DTS let
you configure the delimiter character.
If it's non-delimited then I assume each column is a fixed width. The
text file source driver supports fixed width columns too. In the DTS
designer select the connection properties dialog to configure the
column positions.
David Portas
SQL Server MVP
--|||Why not use the files through a linked server to text files?
More info here:
http://msdn.microsoft.com/library/d...r />
_6a44.asp
And of course *you* have the power to describe, rather to transform your
text files:
http://msdn.microsoft.com/library/d...ma_ini_file.asp
After establishing links to your text files, you can query them with T-SQL
as you would any other SQL table.
ML

No comments:

Post a Comment