EXEC [dbo].[pr_cfgAddFact]
@SettingName = 'TransferBatch',
@RoleFK = SELECT TOP 1 rolepk FROM cfgRole WHERE cfgRole.Name = 'SuperAdmin'
爲什麼SQL抱怨這裏的SELECT子句?我試圖運行與子查詢獲取數據的過程。SQL Server 2005:EXEC中的子查詢?
EXEC [dbo].[pr_cfgAddFact]
@SettingName = 'TransferBatch',
@RoleFK = SELECT TOP 1 rolepk FROM cfgRole WHERE cfgRole.Name = 'SuperAdmin'
爲什麼SQL抱怨這裏的SELECT子句?我試圖運行與子查詢獲取數據的過程。SQL Server 2005:EXEC中的子查詢?
試試這個:
DECLARE @RoleFK_value {datatype here}
SELECT TOP 1 @RoleFK_value=rolepk FROM cfgRole WHERE cfgRole.Name = 'SuperAdmin'
EXEC [dbo].[pr_cfgAddFact]
@SettingName = 'TransferBatch',
@RoleFK = @RoleFK_value
你不能有內執行該過程的查詢,存儲過程的參數不允許這樣。首先,首先將值選擇爲局部變量,然後將該局部變量傳遞給存儲過程。
存儲過程參數可能只是值,@variables或關鍵字DEFAULT
,這意味着查詢和表達式礦石不允許的。
Execute a stored procedure or function
[ { EXEC | EXECUTE } ]
{
[ @return_status = ]
{ module_name [ ;number ] | @module_name_var }
[ [ @parameter = ] { value
| @variable [ OUTPUT ]
| [ DEFAULT ]
}
]
[ ,...n ]
[ WITH RECOMPILE ]
}
[;]
嘗試
SELECT TOP 1 @RoleFK=rolepk FROM cfgRole WHERE cfgRole.Name