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)
 Importing Date

Author  Topic 

alexta
Starting Member

2 Posts

Posted - 2002-10-08 : 03:54:05
I have ASCII file that has three field (Date, Hour & Minutes - eg. "08/22/2002", 15, 1) delimited by comma. I want to import all fields into one field (datetime datatype) in SQL Server 2000.
How can i do with DTS ActiveX Script ?
Thanks in advance.


M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-10-08 : 12:51:05
You'll need 3 dts steps.

step one:
In this case I would create a temporary table with three coloumns.
create ##load_date_temp
(date varchar(8),
hours varchar(2),
minutes varchar(2)
)
step 2:
Load this table.

step 3:

Inside the dts package you can then run a sql query that combines this into one field and inserts into your actual table.

If you need help with that insert statement, I'll gladly assist there too. just post.

a 4th step would be finally to drop that table

-----------------------
SQL isn't just a hobby, It's an addiction
Go to Top of Page

alexta
Starting Member

2 Posts

Posted - 2002-10-08 : 23:40:32
What function is used in query to convert all three varchar data into datetime data type field in actual table ?

Thanks in advance

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-09 : 09:06:29
Using M.E.'s design, something like this should work:

INSERT INTO newTable (dateCol)
SELECT DateAdd(h, hours, DateAdd(minute, minutes,[Date])) FROM ##load_date_temp


You'll need to change the table structure so that the hours and minutes columns are int instead of varchar.

Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-10-09 : 11:50:54
Bleh, you could always convert to int inside the insert statement rather than change the column to type int. I guess its probably easier just to do what rob says.

Damnit, I just just put my signature back to
"Just do what rob or page say"

-----------------------
SQL isn't just a hobby, It's an addiction
Go to Top of Page
   

- Advertisement -