SQL: avoiding hard-coding or magic numbers

后端 未结 11 1395
无人及你
无人及你 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 18:09

    I recently figured out that magic numbers can be implemented by views:

    CREATE VIEW V_Execution_State AS
    SELECT 10 AS Pending, 20 AS Running, 30 AS Done
    
    DECLARE @state INT
    SELECT @state = Pending FROM V_Execution_State
    

提交回复
热议问题