2013-04-18 55 views
-5
SELECT * 
FROM [Live].[Test] 
WHERE [_fk_RoadMapKey] = @_fk_RoadMapKey 

SELECT @TestKey = [TestKey] 
FROM [Live].[Test] 
WHERE [_fk_RoadMapKey] = @_fk_RoadMapKey 

SELECT * 
FROM [Live].[SetofTestGrades] 
WHERE [_fk_TestKey] = @TestKey 

前兩個語句中,我們可以做到讓所有的測試,因爲我們分配語法將兩個存儲過程爲一個

SELECT * ,@TestKey = [TestKey] FROM [Live].[Test] 
    WHERE [_fk_RoadMapKey] = @_fk_RoadMapKey 
+2

這是怎麼涉及到合併兩個STO紅色程序? –

回答

0

您不能分配數據給一個變量,並返回數據的密押同時使用SELECT語句中,如果您正在使用@TestKey可以從另一表中的值,那麼你可以跳過變量,使用加入到另一個表中獲取數據,試試這個

SELECT * 
FROM [Live].[Test] 
WHERE [_fk_RoadMapKey] = @_fk_RoadMapKey 

SELECT S.* 
FROM [Live].[SetofTestGrades] S 
INNER JOIN [Live].[Test] T ON S.[_fk_TestKey] = T.[TestKey] 
WHERE t.[_fk_RoadMapKey] = @_fk_RoadMapKey 
+0

誰投票我的答案,請關注發佈downvoting的原因? –

相關問題