Exec usp_RmsExecuteValidationRule 1
当我们@RULE_QUERY
时,它返回SELECT GDMID AS GDM_ID from @FIPSName+CADMIN1 WHERE INTPRIORITY IS NULL
,即:
LCountry
这里我故意添加了@ FIPSName + As前缀,因为我有另一个表FIPS
和FIPS
----
GM
FR
UK
AN
BE
BU
BL
BR
BH
CA
AU
VT
CI
CH
CO
CS
EZ
AS
DA
EC
SP
AR
BD
BB
BF
AV
AA
AC
DO
CU
CJ
DR
GP
GJ
HA
JM
ST
RQ
SC
MB
MH
XN
XM
XJ
VC
VI
TK
TD
TB
RN
XL
XK
VQ
GR
GT
GQ
HK
HO
HU
ID
EI
IS
GZ
XC
WE
IN
IT
SM
JA
LS
LU
MX
NU
NL
NO
NZ
PM
PE
RP
PL
PO
RO
SW
SI
LO
ES
TU
TW
SZ
VE
SN
SB
PF
PG
PC
NE
NF
MQ
US
SX
TE
TT
WQ
BQ
DQ
BS
CK
CQ
CR
AY
AT
BV
LQ
KQ
JQ
JU
KT
IO
IP
列:
DECLARE @LoopCounter INT , @MaxBcountryObjId INT,
@FIPSName NVARCHAR(100)
SELECT @LoopCounter = min(OBJECTID) , @MaxBcountryObjId = max(OBJECTID)
FROM dbo.LCOUNTRY
WHILE(@LoopCounter IS NOT NULL
AND @LoopCounter <= @MaxBcountryObjId)
BEGIN
SELECT @FIPSName = FIPS
FROM dbo.LCOUNTRY WHERE OBJECTID = @LoopCounter
PRINT @FIPSName
SET @LoopCounter = @LoopCounter + 1
使用循环我可以使用Lcountry的ObjectID获取数据。
SELECT GDMID AS GDM_ID from @FIPSName+CADMIN1 WHERE INTPRIORITY IS NULL
Changes Into
SELECT GDMID AS GDM_ID from GM+CADMIN1 WHERE INTPRIORITY IS NULL
Changes Into
GDMID
------ (The above query must be executed and Return GDMID.)
1198
此查询返回@FIPSName。
问题
我想要返回值@FIPName应该追加到Rule_Query返回值。 并且也可以执行相同的值。
例如:
{{1}}
答案 0 :(得分:0)
据我了解你想要执行
SELECT @RULE_QUERY=RULE_QUERY from GdmValidationRuleMaster where RULE_ID = @nRuleId
以上查询将为您提供结果。
我认为您不需要使用sp_executesql。