嗨我有一個存儲過程的輸出參數,其值必須從兩個內部選擇語句中返回。我有@nTotalRecords
作爲我的輸出參數值將來自以下select語句應該怎麼檢索表的別名TBL
輸出參數在這種情況下,我想這樣的從具有多個返回值的select語句中檢索輸出參數值以及其他返回值
create procedure [usp_GetMessagesbyReferenceID1]
(
@nRowsPerPage int,
@nPage int,
@nTotalRecords int output
) as
select
TBL.createdate,
TBL.templateid,
@nTotalRecords=TBL.TotalRecords
from
(
select
message.createdate,
message.templateid,
count(1) over() as TotalRecords
from
nts.Messages as [message]
) as TBL
我試圖這樣說來設置輸出參數但它不工作它是拋出以下錯誤A SELECT statement that assigns a value to a variable must not be combined with data retrieval operations.
有沒有可能實現這一點。 ?或者我在語法上犯了任何錯誤,請幫助我。
注: 從select語句的輸出參數的檢索工作正常,如果它僅返回一個值(輸出參數值),但我的要求是它應能正常工作時,我的select語句返回多個值(包括輸出參數)。
標記您正在使用的dbms。該代碼是特定於產品的。 – jarlh
@jarlh相應地添加了標籤 – Meena
@MarekGrzenkowicz我的要求是返回 – Meena