-2

I have a stored procedure that updates my table data.

update tbl_duty
set Name = @DName,
    Necessity = @DNecessity,
    Payment = @DPayment,
    [Estimation Time] = @DEstimationTime,
    Term = @DTerm,
    [Description] = @DDescription
where 
    Id = "what can I put here"

but I don't now how get the ID of column to update because it generated itself (identity column)

Anyone can help me?

Do we have something like GETIDENTITY(column name)?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Do you want something like this?

update tbl_duty
set Name = @DName,
    Necessity = @DNecessity,
    Payment = @DPayment,
    [Estimation Time] = @DEstimationTime,
    Term = @DTerm,
    [Description] = @DDescription
where id = (select max(id) from tbl_duty);

This seems very dangerous. Why wouldn't you insert the records with the right values in the first place?

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786