Is there a way to make a TSQL variable constant?

前端 未结 12 1178
别那么骄傲
别那么骄傲 2021-02-01 11:31

Is there a way to make a TSQL variable constant?

12条回答
  •  萌比男神i
    2021-02-01 12:16

    No, but you can create a function and hardcode it in there and use that.

    Here is an example:

    CREATE FUNCTION fnConstant()
    RETURNS INT
    AS
    BEGIN
        RETURN 2
    END
    GO
    
    SELECT dbo.fnConstant()
    

提交回复
热议问题