Hi guys,I'm trying to update a column in all rows of a table, replacing the last character with a character I find in another table. I've been fooling around with this all morning and doing searches but I can't quite seem to find the solution.Here is my test tableCREATE TABLE [user_test] ( [amount] [char] (12) NULL ) ON [PRIMARY]GO
and I seeded it thusly:declare @x as intselect @x = 1While @x < 2500begin insert into user_test (amount)values (convert(char(12),(convert(DECIMAL(10,2),@x * 3.14159))))select @x = @x+1end
I need to replace the last digit in the above table with the match found in the following small tableCENT_VALUE POS_SYMBOL NEG_SYMBOL ---------- ---------- ---------- 0 { }1 A J2 B K3 C L4 D M5 E N6 F O7 G P8 H Q9 I RThis is the last piece of code I futzed withupdate user_test set amount = (left(amount,len(amount)-1) + (SELECT POS_SYMBOL FROM SIGN_CONVERSION WHERE CENT_VALUE = right(amount,1)))While it doesn't work, I think it gives you a good idea of what I'm after. The current code creates a cursor and then calls another subroutine that updates the passed field. I know there is a better way and I think I'm close. I tried writing a correlated subquery but I couldn't get it to work quite right.suggestions?Edited by - cat_jesus on 10/08/2001 11:54:58