Declare @AutoId Numeric(9)
Declare @StrButton Varchar(100)
Declare @UserId Smallint

Declare Select_Cursor Cursor For
Select [Manager].dbo.Pass.UserId From [Manager].dbo.Pass Where UserName <> 'test'
Open Select_Cursor
Fetch Next From Select_Cursor Into @UserId
While @@Fetch_Status = 0 
Begin
  IF (Select Count(*) From [Manager].dbo.StatusFormButton Where iUserCode = @UserId And iFormTag = 15100) > 0 
  Begin
    Select @StrButton = [Manager].dbo.StatusFormButton.StrButton From [Manager].dbo.StatusFormButton
    Where iUserCode = @UserId And iFormTag = 15100
 
    Update [Manager].dbo.StatusFormButton Set [Manager].dbo.StatusFormButton.StrButton = (SELECT STUFF(@strButton, 62, 1, '1'))
    Where iUserCode = @UserId And iFormTag = 15100
  End 
  Fetch Next From Select_Cursor Into @UserId
End
Close Select_Cursor
Deallocate Select_Cursor



