create a staging table where you have a YourDateString
column to be populated by the data, and then an actual datetime column YourDate
, which you will update in a different step. like this:
DECLARE @YourTable table(YourDateString varchar(11), YourDate datetime)
--simulate bulk load
INSERT INTO @YourTable VALUES ('01-JAN-1976',null)
INSERT INTO @YourTable VALUES ('02-FEB-1980',null)
INSERT INTO @YourTable VALUES ('05-MAR-1991',null)
INSERT INTO @YourTable VALUES ('12-APR-1997',null)
INSERT INTO @YourTable VALUES ('22-MAY-1990',null)
INSERT INTO @YourTable VALUES ('18-JUN-1971',null)
INSERT INTO @YourTable VALUES ('17-JUL-1988',null)
INSERT INTO @YourTable VALUES ('19-AUG-1993',null)
INSERT INTO @YourTable VALUES ('19-SEP-1970',null)
INSERT INTO @YourTable VALUES ('04-OCT-1982',null)
INSERT INTO @YourTable VALUES ('08-NOV-1970',null)
INSERT INTO @YourTable VALUES ('18-DEC-1983',null)
--convert to proper datetime
UPDATE @YourTable
SET YourDate= CONVERT(datetime,YourDateString)
--show data
select * from @YourTable
OUTPUT:
YourDateString YourDate
-------------- -----------------------
01-JAN-1976 1976-01-01 00:00:00.000
02-FEB-1980 1980-02-02 00:00:00.000
05-MAR-1991 1991-03-05 00:00:00.000
12-APR-1997 1997-04-12 00:00:00.000
22-MAY-1990 1990-05-22 00:00:00.000
18-JUN-1971 1971-06-18 00:00:00.000
17-JUL-1988 1988-07-17 00:00:00.000
19-AUG-1993 1993-08-19 00:00:00.000
19-SEP-1970 1970-09-19 00:00:00.000
04-OCT-1982 1982-10-04 00:00:00.000
08-NOV-1970 1970-11-08 00:00:00.000
18-DEC-1983 1983-12-18 00:00:00.000
(12 row(s) affected)