SQL: avoiding hard-coding or magic numbers

后端 未结 11 1430
无人及你
无人及你 2020-12-14 17:18

Question: What are some other strategies on avoiding magic numbers or hard-coded values in your SQL scripts or stored procedures?

Consider a stored

11条回答
  •  爱一瞬间的悲伤
    2020-12-14 17:55

    This is how I would do it. (Because it is much faster than your example)

    UPDATE SomeTable
    SET CurrentStatusID = [Status].[ID]
    FROM SomeTable
     RIGHT JOIN [Status] ON [Name] = 'Acknowledged'
    WHERE SomeTable.[ID] = @SomeID
    

    (not tested could have typos)

提交回复
热议问题