Declare @Id varchar(20) @H_4030@Declare @Name varchar(20) @H4030@Declare Cur Cursor For @H4030@select substring(id,7) as id,name from temp1 @H4030@Open Cur @H4030@Fetch next From Cur Into @Id,@Name @H403_0@While @@fetchstatus=0 @H4030@Begin @H4030@Update temp Set [c3]=@Name where [id] like @Id+'%' @H4030@Fetch Next From Cur Into @Id,@Name @H4030@End @H4030@Close Cur @H4030@Deallocate Cur @H403_0@