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)
 Data Import

Author  Topic 

vwilsonjr
Starting Member

45 Posts

Posted - 2003-04-01 : 11:38:40
I have a flat file with date fields in it. I'm trying to import it into a table. When I use DTS it barks at the date field during the translation. Any suggestion. Here is an example of the text file
John Smith 10/20/52

Table Design is
FName varchar 25
LName varchar 25
DOB datetime 8

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-01 : 11:59:02
Why use dts to import a flat file?
You can do it in one line of sql using bulk insert if it's simple.

I would always import into a staging table then transfer (ok that's 2 sql commands) and you can reformat the (char) date while doing that.

==========================================
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

vwilsonjr
Starting Member

45 Posts

Posted - 2003-04-01 : 12:09:16
Can you direct me where I can find out how to do that?

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-01 : 12:09:38
create table ##a (fname varchar(25), lname varchar(25), dte varchar(10))

exec master..xp_cmdshell 'bcp ##a in e:\tst.txt -c -t" "'
select fname, lname, convert(datetime,dte,1)
from ##a

drop table ##a

==========================================
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

vwilsonjr
Starting Member

45 Posts

Posted - 2003-04-01 : 12:12:30
Real dump question, I havent done much in sql. Is ##a = table name?

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-01 : 12:35:34
global temp table so can be created in the sp.
you might want a permanent one.


==========================================
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

vwilsonjr
Starting Member

45 Posts

Posted - 2003-04-01 : 13:11:56
Thanks for all your help. Could you explain the "dte varchar(10)" What does the dte mean.

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-04-01 : 13:31:49
dte is just a column name. It could be named anything.

You really need to have a look at the CREATE TABLE statement and the SELECT statement in SQL Server Books Online so that you can decipher what everything means.

Tara
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-01 : 13:31:55
dte is the name of the field.
You can call it DOB if you wish.

==========================================
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 -