是否可以在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