首先,如果找到代理名称,我必须从查询表中找到代理名称,然后如果未找到代理名称,则如果部分将 wrk n,则第二个查询 dat 是其他部分将起作用。以下是我的查询,请让我知道我哪里错了。提前致谢
create proc ConfirmationMail_ToAgent
(
@Enquiry_Id nvarchar(50)
)
as
begin
select Agent_Name from Enquiry where Enquiry_Id = @Enquiry_Id as jh
if(jh != 'Select')
begin
select e.Agent_Name,e.Agent_Email,e.Client_Name,e.Handled_By,ef.EMail_Id from Enquiry e inner join Employee_FullDetail ef on e.Handled_By = ef.First_Name where e.Enquiry_Id = @Enquiry_Id
end
else
begin
select e.Client_Name,e.Client_Address,e.Handled_By,ef.EMail_Id from Enquiry e inner join Employee_FullDetail ef on e.Handled_By = ef.First_Name where e.Enquiry_Id = @Enquiry_Id
end
end