是否可以在TSQL存儲過程中包含一組「常量」值?我在那裏我使用整型字段存儲位值的情況下,我有小套,我使用插入/選擇對那場「常量」值TSQL中的常量和包含文件
DECLARE @CostsCalculated int = 32
DECLARE @AggregatedCalculated int = 64
--Set CostCalculated bit
update MyTable set DataStatus = ISNULL(DataStatus, 0) | @CostsCalculated
where Id = 10
--How many rows have that bit set
select count(*) from MyTable where ISNULL(DataStatus, 0) & @CostsCalculated = @CostsCalculated
我可以重複同一套在每個SP的頂部聲明,但我寧願包含代碼,這意味着我可以在添加新位值時在一個位置進行更改。
您可以隨時將常量存儲在表中。 – 2010-07-14 03:14:06
我仍然必須將鍋爐板代碼剪切/粘貼到所有SP中,或者加入到那個表現糟糕的表現中。 – MrTelly 2010-07-27 23:26:46