我有6个表格: LS_CLIENT_INSEE_A、B、C 等。 每个表格仅包含1个领域:INSEE。
我只想知道,我是否在其中一个表格中提出意见,并从表格名称(A、B、C等)中退回相应的信函。
还有一种原因,这就是:
@TheInsee int
AS
BEGIN
declare @Zone char(1)
declare @CountA int
declare @CountB int
declare @CountC int
declare @CountD int
declare @CountF int
declare @CountP int
SELECT @CountA = COUNT(*) FROM LS_CLIENT_INSEE_A WHERE NO_INSEE = @TheInsee
SELECT @CountB = COUNT(*) FROM LS_CLIENT_INSEE_B WHERE NO_INSEE = @TheInsee
SELECT @CountC = COUNT(*) FROM LS_CLIENT_INSEE_C WHERE NO_INSEE = @TheInsee
SELECT @CountD = COUNT(*) FROM LS_CLIENT_INSEE_D WHERE NO_INSEE = @TheInsee
SELECT @CountF = COUNT(*) FROM LS_CLIENT_INSEE_F WHERE NO_INSEE = @TheInsee
SELECT @CountP = COUNT(*) FROM LS_CLIENT_INSEE_P WHERE NO_INSEE = @TheInsee
set @Zone =
CASE
WHEN @CountA > 0 THEN A
WHEN @CountB > 0 THEN B
WHEN @CountC > 0 THEN C
WHEN @CountD > 0 THEN D
WHEN @CountF > 0 THEN F
WHEN @CountP > 0 THEN P
END
END
是否有最佳办法实现这一目标?
Thanks you in advance, Stev