从存储过程中的不同表中返回多个select

时间:2018-02-10 15:14:23

标签: sql-server

编写以下存储过程,但仅在向Crystal Report添加存储过程时显示第一个select语句中的列。我想将所有select语句作为单个select语句:

CREATE PROCEDURE [dbo].[GetPublishedJobInfo]   
    @JobId INT,
    @EmployerId NVARCHAR(128)  
AS
    SELECT
        logoImage, 
        CONVERT(DATE, GETDATE())  
    FROM 
        EmployerInfoes 
    WHERE
        id = @EmployerId  

SELECT 
    jobName, PublishedDate,  
    DATEDIFF(DD, DurationAvailableForApply, current_timestamp) 
       - CASE WHEN (MONTH(DurationAvailableForApply) > MONTH(current_timestamp)) OR (MONTH(DurationAvailableForApply) = MONTH(current_timestamp)  
AND DAY(DurationAvailableForApply) > DAY(current_timestamp)) 
                 THEN 1 ELSE 0 
          END   
FROM
    jobs 
WHERE 
    Id = @JobId  

SELECT COUNT(*)  
FROM ApplyForJobs  
WHERE JobId = @JobId  

SELECT COUNT(*)  
FROM JobViewNumbers  
WHERE JobId = @JobId  

SELECT 
    PersonalPhotoImage, firstName + middleName + lastName,
    phoneNumber, Email, gender, country   
FROM
    JobSeekerInfoes 
WHERE
    id = (SELECT UserId 
          FROM ApplyForJobs 
          WHERE JobId = @JobId) 

0 个答案:

没有答案