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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Bulk Import

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2012-07-09 : 06:36:27
I have file which is imported to table raw, now the raw table has Id column and raw_col which contains entire line of data file imported to it.

Now this raw_col has data in fixed width, I want to copy this data to proper table, please help me in using

bulk import or any for doing so, Also I want to ignore data after #, as that is comment


tcp 1/tcp # TCP Port
tcp 1/udp # TCP Port
comp 2/tcp # Management
comp 2/udp # Management
comp 3/tcp # Compression



-Neil

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-07-09 : 07:05:31
Since you have fixed with columns, you can easily use the SUBSTRING function. For example,

INSERT INTO YourProperTable
(Col1, Col2)
SELECT
SUBSTRING(RawTableCol,1,12),
SUBSTRING(RawTableCol,13,24)
FROM
YourRawTable;
You may also want to use RTRIM function to trim off any trailing spaces if required.
Go to Top of Page
   

- Advertisement -