This is a sql datatype problem

Hello
I am a junior programmer and new member of this forum

I want to ask a question

I have these two columns in sql 2000 server

trx_date char(8)
trx_time char(6)

And now, I imported this database to sql 2008

and want to copy those two columns' record to a new column call
trx_datetime (datetime)


Please guide me , thanks

Recommended Answers

All 2 Replies

trx_datetime = concat(trx_date, trx_time)

or something pretty close.

HI

I got the solution, and share it

Like this

INSERT INTO ABC(datetime, sn)
SELECT
convert(datetime,
RTRIM(LTRIM(trx_date))+' '+
SUBSTRING(trx_time,1,2) + ':' +
SUBSTRING(trx_time,3,2) + ':' +
SUBSTRING(trx_time,5,2), 120),
sn
FROM orders WHERE sn = '123456789';


Thank you rch1231

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.