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)
 Text to Sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-31 : 10:32:00
Vahid writes "Hi there

I have a text file as follows:
16/08/2006,14:57:11,0,009
16/08/2006,08:27:44,1,009
16/08/2006,14:27:52,0,012
16/08/2006,08:30:24,1,012


I want to insert this information into a table with following settings:
emNo| Date | TimeIn1 |TimeOut1
----+-----------+---------+--------
009 |16/08/2006 | 08:27:44|14:57:11
----+-----------+---------+--------
012 |16/08/2006 | 08:30:24|14:27:52"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-31 : 10:51:10
create table #a
(
d varchar(10) ,
t varchar(8) ,
type int ,
id int
)
bulk insert #a from 'c:\myfile.txt' with (fieldterminator = ',')
insert tbl (empno, date, timein1, timeout1)
select t1.id, t1.d, t2.t, t1.t
from #a t1
join #a t2
on t1.id = t2.id
and t1.type = 1
and t2.type = 2


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -