我想通過使用存儲過程從我的數據庫中選擇最後一個記錄值,要做到這一點我將@UPID
參數設置爲SCORE_IDENTITY()
,但沒有輸出結果,因爲我執行後我的存儲過程使用存儲過程來選擇最後一項值
CREATE PROCEDURE [dbo].[spAuditLogSelect_NewUser]
@UPID int
AS
BEGIN
SET @UPID = SCOPE_IDENTITY()
SELECT
siUserProfile.UPID
,siUserProfile.ProfileType, siProfileType.RGDName AS ProfileTypeName
,siUserProfile.CBID, siCompany.ComName + ' - ' + siComBranch.ComBranchName AS CBName
,siUserProfile.FullName
,siUserProfile.ShortName
,siUserProfile.SerialCode
,siUserProfile.Serial
,siUserProfile.Gender
from siUserProfile WITH (NOLOCK)
inner join siUserProfileDetail WITH (NOLOCK) on siUserProfile.upid = siUserProfileDetail.UPID
left outer join siReferenceGroupDetail siProfileType WITH (NOLOCK) ON siUserProfile.ProfileType = siProfileType.RGDID
left outer join siComBranch WITH (NOLOCK) on siComBranch.CBID = siUserProfile.CBID
left outer join siCompany WITH (NOLOCK) ON siComBranch.CompanyID = siCompany.CompanyID
where siUserProfile.UPID = @UPID
你是什麼意思的「沒有輸出結果」? proc返回一個空表或者沒有返回? 如果您不能看到輸出,請按Display Estimation Plan按鈕。該操作可以建議您創建一個最有可能解決您的問題的索引。 – 2013-05-02 11:24:49