Question : stored procedure to update field with a value in another table

greetings,

I have two tables and a column in one of those tables that I would like to update.  

table1                      table2
col 1 = 123             col1 = 10
col 2 = null             col2 = xxx_123_xxx

In this scenario, I would like table1.col2 = table2.col1 based off of table1.col1 being a substring of table2.col2.  

I have a stored procedure that will give me the value of table2.col1 from a parameter that I pass in but I am not sure
If I need to do this all in stored procedure or just a single update statement and also should I use a cursor or is there
some better way to loop through the data and do an update.  

Thanks in advance.

Answer : stored procedure to update field with a value in another table

UPDATE A
SET A.Col2 = B.Col1
FROM Table1 AS A
JOIN TABLE2 AS B
ON CHARIDX (A.Col1, B.Col2) > 0
Random Solutions  
 
programming4us programming4us