How to Create a "Global Constant" in SQL Server

  • Hey guys

    In several of my stored procedures I assign the default value of a parameter as -2147483648 (Int32.MinValue) as well as do comparisons on that value. How can one abstract that away to a global variable of sorts?

    It would help me feel more confident that a typo hasn't occurred and that whoever maintains this database has one less thing to worry about. If this needs changing it would speed up the change process quite a bit (even though Redgate has a fantastic - free! - SQL Search tool 🙂 and change isn't my primary motivation in this)

    Thanks

  • Unfortunately there's not a built-in tool to do that.

    When I have to achieve the same thing I usually put the contants in a "global parameters" table.

    To cut down the code lines you could also wrap it with a scalar UDF.

    Hope this helps

    -- Gianluca Sartori

  • Thanks Gianluca.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply