| Author |
Topic  |
|
|
keesky
Starting Member
2 Posts |
Posted - 04/23/2008 : 08:33:18
|
Hello everyone...
I am using SQL Server Enterprise Manger Version 8.0, and I need to update the values of Field one into a new Field of a different type. Here is my example, say I have a table called tblResults with field name "resultOne" and I want to update the values of "resultOne" into a new Field called "resultTwo", but resultOne is of type "nvarchar" and resultTwo needs to be of type "int". I need to run an update query that copies all the values of resultOne into resultTwo? Is there any way I can make the string values to be copied into the int values.
All the values in resultOne have numbers but the type is "nvarchar"?
Hence resultOne has values like 12.09, -100.98, 2827.98 and all of them are numbers, so there must be some way to copy it into resultTwo that is of type "int", I cannot manually do it because i have 35,000 records.
Could someone guide me in the right direction.
Thanks, |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
Posted - 04/23/2008 : 08:38:11
|
try using CAST function
UPDATE Table SET resultTwo=CAST(resultOne as int) |
 |
|
|
keesky
Starting Member
2 Posts |
Posted - 04/23/2008 : 09:01:17
|
| Hi thats the function works perfectly, thanks very much |
 |
|
|
chandan_joshi80
Starting Member
India
30 Posts |
Posted - 04/24/2008 : 05:47:38
|
UPDATE TEMPTABLE2 SET COL2 = CONVERT(INT,S.COL2) FROM TEMPTABLE2 t, MASTERTABLE2 s WHERE t.COL1 = s.COL1
chandan Joshi |
 |
|
| |
Topic  |
|