存儲過程的結果我有一個存儲過程,這是否......不正確的語法:包括在SELECT語句
CREATE PROCEDURE spGetRegion @postcode nvarchar(10)
AS
SELECT capt FROM REGION_DATA
where POSTCODE = @postcode
go
這意味着我可以運行
exec spGetCounty @postcode = 'rh12'
並返回一個區域,如「東南部」
是否可以在select語句中包含像這樣的存儲過程的結果,例如
SELECT
FIRST_NAME
, LAST_NAME
, POSTCODE
, << NEED TO INCLUDE RESULTS OF STORED PROCEDURE HERE PASSING IN POSTCODE
FROM PEOPLE
因此,像
SELECT
FIRST_NAME
, LAST_NAME
, POSTCODE
, exec spGetCounty @postcode = 'rh12' << THIS BIT DOESN'T WORK !!
FROM PEOPLE
什麼想法?
u可以使用表值函數... – 2014-10-29 10:27:50
選中此http://stackoverflow.com/questions/14506871/how-to-execute-a-stored- procedure-inside-a-select-query – 2014-10-29 10:30:46