0
I have the following update:
update ex
set ex.seq_docum_ref = '00001',
ex.nr_chv_nfe_ref = ref.ChaveNfTerceiro,
ex.cd_docum_ref = case when ChaveNfTerceiro is not null then coalesce(ref.DocSispro,'') else case when ref.SerieNotaProd is not null then 'NFP'+cast(ref.SerieNotaProd as varchar) else '' end end,
ex.cd_docum_nr_ref = ref.NrNfTerceiro,
ex.cd_pessoa_ref = ex.cd_pessoa_emi,
ex.dt_nota_ref = replace(convert(varchar, ref.DtNfTerceiro,103),'/',''),
ex.in_ent_sai = 'S'
in the field
ex.seq_docum_ref
I want it to add one more to each update performed, however the field is varchar, how can I make this addition and keep the field type? I need it to deliver an assignment to work. Thanks in advance!
You can do the operation with a Convert, but the ideal is to change this field to a numeric.
– gmsantos
@gmsantos Could exemplify the operation with Convert?
– Renan Goulart
@Renangoulart
SELECT CONVERT(int, '42') + CONVERT(int, '42')
returns 84 for example.– ThRnk
For your case, it would be better to take a look at the definition of
trigger
, is what you’ll need.– ThRnk
@Thrnk I was wondering how I would apply this in this update, I would have some example please?
– Renan Goulart