-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
  • 704,970
  • 168
  • 1,303
  • 1,425

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,198,228
  • 53
  • 572
  • 709