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 |
donchamp
Starting Member
9 Posts |
Posted - 2010-07-03 : 20:44:43
|
I a table with the following data:Sortcode Code Length-------- ---- ------ abcdI need to retrieve only the last character and update the code column with that character. I then need to update the length column with the length of the Sortcode column. I executed the following code and the code transformation was successful but I got nulls in the length column. Kindly suggest how I can resolve this.update TempTable set code = right(Sortcode,1)where right(Sortcode,1) is not null GOSELECT leng = DATALENGTH(Sortcode), SortcodeFROM TempTableUpdate TempTableset ID = leng |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-07-04 : 02:56:33
|
Try this:Update TempTable Set Code = right(Sortcode,1), Length = Len(SortCode)where Sortcode is not nullRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
donchamp
Starting Member
9 Posts |
Posted - 2010-07-04 : 12:02:09
|
Thanks Bohra, I tried it and it worked perfectly.Regards, Don |
 |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-07-05 : 00:23:11
|
Glad to help |
 |
|
|
|
|