We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,039 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

sql datatype problem

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

2
Contributors
2
Replies
2 Hours
Discussion Span
2 Years Ago
Last Updated
3
Views
chfunglukas
Newbie Poster
2 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

trx_datetime = concat(trx_date, trx_time)

or something pretty close.

rch1231
Veteran Poster
1,040 posts since Sep 2009
Reputation Points: 142
Solved Threads: 154
Skill Endorsements: 12

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

chfunglukas
Newbie Poster
2 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0676 seconds using 2.67MB