Click to See Complete Forum and Search --> : Insert Concatenated Values into Row


baldwingrand
03-13-2009, 12:01 PM
I have four tables: ClockHours, ClockMinutes, TimeofDay, and TimeZones. There is a front-end ASP page in which the user is selecting (via dropdown) from each of these tables to produce something eventually mimics a datetime. (I won't go into the minutaie, but simply using a datetime won't work here.)

My question is- I'd like to concatenate these values and do an insert on them into one field in another table. So, the concatenated value might look like so:

'1' + ':' + '00' + ' ' + 'AM' + ' ' + 'Central Time (CST)'

I want to insert the above value into the "DropTime" field of "tblInput." Is this possible, or am I making things harder than they need to be? Thanks.

Kuriyama
03-13-2009, 01:23 PM
It's possible, but you are really backing yourself into a corner if you are going to do any data mining.

By storing this data as a string you might run into instances where you need to try to sort by or manipulate this data.
I would recommend that you change your table so that each part has a datatype that better represents the data in that field. For instance.

Hours - smallInt
Minutes - smallInt
AM/PM = bit or tinyint (0 for AM and 1 for PM)
timezone = varchar(20)

Keep the data clean and when you pull it out of SQL, just CAST each part as a varchar and concatenate them.


Hope this helps.