我有大量存储的过程,它们都执行相似的选择逻辑位:
WHERE
@CustGroup = 'X' AND CUST_TYPE in ('X1', 'X2', 'B1', 'C1')
OR
@CustGroup = 'Y' AND CUST_TYPE in ('Y1', 'A1', 'B2', 'C2')
OR
@CustGroup = 'Z' AND CUST_TYPE in ('X2', 'Y2', 'D1', 'D2')
OR
@CustGroup = 'MAIN' AND CUST_TYPE in ('Y1', 'A1', 'B2', 'C2', 'X2', 'Y2', 'D1', 'D2')
是否有可能:
一种)
将这些“输入”选择放入某种变量中?
@XGroup = 'X1', 'X2', 'B1', 'C1'
WHERE
@CustGroup = 'X' AND CUST_TYPE in (@XGroup)
如果是这样 B)
将这些“in”选择集中放置在某个地方,以便它们可以与不同的存储过程重复使用?