/****** Script do comando SelectTopNRows de SSMS  ******/
SELECT
		concat('UPDATE TBMODELO SET CODIGOORIGINAL = ',[CodigoOriginal],' WHERE CODIGO = ', [Alphaind].[dbo].fn_sub([Referencia]),';')
      
  FROM [Alphaind].[dbo].[Produtos] a, [Alphaind].[dbo].[TiposdeGrade] b
  where a.Grade = b.Codigo