我几个小时以来一直在努力解决这个问题。我对存储过程很陌生,我遇到了这个问题,我无法通过任何方式解决这个问题,我相信它是一个小愚蠢的东西,但我无法弄清楚< / p>
CREATE PROCEDURE [dbo].[IntegrationGetKuwaitPrize]
@ApplicationID int,
@ChosenFieldOfAward nvarchar(MAX) out
AS
declare @ID int = (select top (1) ID
from [dbo].[KuwaitPrizeApplicarion]
where [ApplicationID] = @ApplicationID);
SELECT
[CurrentAddress] as [current_address] /* I'm getting the error at this line */
, (SELECT [dbo].[Country].NameEN from [dbo].[Country]
where [dbo].[Country].ID =
(SELECT [dbo].[KuwaitPrizeApplicarion].[PastNationality]
FROM [dbo].[KuwaitPrizeApplicarion]
WHERE [dbo].[KuwaitPrizeApplicarion].[ApplicationID] = @ApplicationID)) AS [past_nationality]
, (SELECT [dbo].[Country].NameEN
FROM [dbo].[Country]
WHERE [dbo].[Country].ID =
(SELECT [dbo].[KuwaitPrizeApplicarion].[PresentNationality]
FROM [dbo].[KuwaitPrizeApplicarion]
WHERE [dbo].[KuwaitPrizeApplicarion].[ApplicationID] = @ApplicationID)) AS [present_nationality]
, [PassportNo] AS [passport_no_]
, [PassportExpireDate] AS [passport_expire_date]
, [PassportIssueDate] AS [passport_date_of_issue]
, (SELECT [dbo].[Country].NameEN
FROM [dbo].[Country]
WHERE [dbo].[Country].ID =
(SELECT [dbo].[KuwaitPrizeApplicarion].[PassportNationality]
FROM [dbo].[KuwaitPrizeApplicarion]
WHERE [dbo].[KuwaitPrizeApplicarion].[ApplicationID] = @ApplicationID)) AS [passport_nationality]
, [YearOFBirth] AS [year_of_birth]
, [EmailAddress] AS [e_mail_address]
, [HomePhoneNo] AS [phone_no_home]
, [WorkPhoneNo] AS [phone_no_work_dir_]
, [PlaceOfBirth] AS [place_of_birth]
, [Mobile] AS [mobile]
, [PassportIssuePlace] AS [passport_place_of_issue]
, [FaxNo] AS [fax_number]
, @ChosenFieldOfAward = (SELECT [dbo].[FieldOfAward].[FieldOfAward]
FROM [dbo].[FieldOfAward]
WHERE [dbo].[FieldOfAward].[ID] =
(SELECT [dbo].[KuwaitPrizeApplicarion].[FieldOfAwardID]
FROM [dbo].[KuwaitPrizeApplicarion]
WHERE [dbo].[KuwaitPrizeApplicarion].[ApplicationID] = @ApplicationID))
, @ChosenFieldOfAward AS [field_of_award]
, (SELECT [dbo].[Topic].TopicName
FROM [dbo].[Topic]
WHERE [dbo].[Topic].[ID] =
(SELECT [dbo].[KuwaitPrizeApplicarion].[TopicID]
FROM [dbo].[KuwaitPrizeApplicarion]
WHERE [dbo].[KuwaitPrizeApplicarion].[ApplicationID] = @ApplicationID)) AS topic_of_award
FROM
[dbo].[KuwaitPrizeApplicarion]
WHERE
ApplicationID = @ApplicationID
RETURN 0
答案 0 :(得分:6)
这是你问题的一个方面,
, [PassportIssuePlace] as [passport_place_of_issue]
, [FaxNo] as [fax_number]
, @ChosenFieldOfAward = (Select [dbo].[FieldOfAward].[FieldOfAward]
from [dbo].[FieldOfAward]
where [dbo].[FieldOfAward].[ID]=select [dbo].[KuwaitPrizeApplicarion]. [FieldOfAwardID]
from [dbo].[KuwaitPrizeApplicarion] where
您正在返回值( PassportIssuePlace )和( FaxNo )以及更新变量 @ChosenFieldOfAward 。
如消息所示,您不能在同一个select语句中同时执行这两个操作。您需要将它们分成两个单独的选择语句。
JOIN语法示例
Select [dbo].[FieldOfAward].[FieldOfAward]
from [dbo].[FieldOfAward] fld
join [dbo].[KuwaitPrizeApplicarion] awd on fld.[ID] = awd.[FieldOfAwardOD]
where awd.[ApplicationID] = @ApplicationID