Link to home
Start Free TrialLog in
Avatar of dastaub
dastaubFlag for United States of America

asked on

import text datetime into SQL

How would I get the last column of the below text table into an SQL field that is a datetime field?  The first two columns are imported into varchar fields.  The last column needs to be converted into a datetime.


0016070|06|20141001|
0016071|06|20141001|
0016072|06|20141001|
0016073|06|20141001|
0016074|06|20141001|
0016075|06|20141001|
0016076|06|20141001|
0016077|06|20141001|
0016078|06|20141001|
001607B|06|20141001|
00160J0|06|20141001|
00160J1|06|20141001|
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dastaub

ASKER

INSERT INTO orders1 ( order_date , ordering_client_id )
VALUES ( cast('20121215' as datetime), 2 )

The above works.  How do you conver this to import hundreds of row?
Depends how are you currently importing your hundreds of rows?
Avatar of dastaub

ASKER

i do not know how to import hundreds of rows
Your question only asks how to import the datetime component, you say "The first two columns are imported into varchar fields". which implies you are already importing the varchar data.

Your question as such has been answered - you should probably ask another question if you need to know how to go about doing an import. And you'll need to specify what format the data is in that you are trying to import e.g. is it just a text file with the data as you listed, and roughly how many rows are there?
Avatar of dastaub

ASKER

tried to sneak one in or keep the conversation going