Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2010-10-22 : 05:53:57
|
hi all, In my table, I have columns day,month,year as separarte fields, now I need to add a new column as date, which will the concatenation of those fields above. My table contains about 1000 records...So I want to get the date-values to new column and need to drop old ones one by one, so that only date-field is there with values?And day,month,year are all int fieldsI added the new field as date with datetime type...What update query I need to perform for this? Thanks in advance |
|
sql-programmers
Posting Yak Master
190 Posts |
Posted - 2010-10-22 : 06:18:07
|
Consider D1 as day columnY1 as year columnM1 as month columnand FinalD as datatime columns.So your update will be,Update table tblTemp set FinalD = convert(datatime, (convert(varchar,M1) + '/' + convert(varchar,D1) + '/' + convert(varchar,Y1)))SQL Server Programmers and Consultantshttp://www.sql-programmers.com/ |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2010-10-22 : 06:26:22
|
Thanks, it worked ....quote: Originally posted by sql-programmers Consider D1 as day columnY1 as year columnM1 as month columnand FinalD as datatime columns.So your update will be,Update table tblTemp set FinalD = convert(datatime, (convert(varchar,M1) + '/' + convert(varchar,D1) + '/' + convert(varchar,Y1)))SQL Server Programmers and Consultantshttp://www.sql-programmers.com/
|
|
|
|
|
|
|
|