本文介绍了加入sql的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hello frnds我在加入时遇到问题...

hello frnds i have a problem in joining ...

alter PROCEDURE [dbo].[sp_GatherCenterInfoForSpecialpaymentsTypes]
(
    @company_u_id int,
    @UnitId int
)
AS
BEGIN
    SET NOCOUNT ON;

    SELECT t1.Center_Name, t1.Center_Code, t1.Center_Id,t1.Center_Id_Format
    FROM DayOpenDayCloseInfo
    INNER JOIN (
        (SELECT CenterInfo.Center_Name, CenterInfo.Center_Code,
         CenterInfo.Center_Id,CenterInfo.Center_Id_Format,
         MAX(DayOpenDayCloseInfo.DayOPenCloseId)
         FROM CenterInfo
         INNER JOIN DayOpenDayCloseInfo
         ON CenterInfo.Center_Id = DayOpenDayCloseInfo.Center_Id
         WHERE (CenterInfo.Unit_Id = @UnitId) AND (CenterInfo.IsActive = 1)
             AND (CenterInfo.company_u_id=@company_u_id)
         GROUP BY CenterInfo.Center_Name, CenterInfo.Center_Code,
             CenterInfo.Center_Id,CenterInfo.Center_Id_Format)
    ) t1
    ON t1.Center_Id = DayOpenDayCloseInfo.Center_Id
    WHERE DayOpenDayCloseInfo.IsActive = 0
END
RETURN



当执行错误时...


when it give error on execute that ...

"Msg 8155, Level 16, State 2, Procedure sp_GatherCenterInfoForSpecialpaymentsTypes, Line 21
No column name was specified for column 5 of 't1'."



i无法理解问题是什么../



这是我加入一个ta的结果集......你在这里看到..



请翻看..提前预订


i am unable to understand what the problem is ../

in this i am joining a result set with an table .... as u see here ..

pls rply ..Thnks in advance

推荐答案

ALTER PROCEDURE [dbo].[sp_GatherCenterInfoForSpecialpaymentsTypes]
(
    @company_u_id int,
    @UnitId int
)
AS
BEGIN
    SET NOCOUNT ON;

    SELECT t1.Center_Name, t1.Center_Code, t1.Center_Id, t1.Center_Id_Format
    FROM DayOpenDayCloseInfo
    INNER JOIN (
        (SELECT CenterInfo.Center_Name, CenterInfo.Center_Code,
         CenterInfo.Center_Id,CenterInfo.Center_Id_Format,
         MAX(DayOpenDayCloseInfo.DayOPenCloseId) AS DayOPenCloseId
         FROM CenterInfo
         INNER JOIN DayOpenDayCloseInfo
         ON CenterInfo.Center_Id = DayOpenDayCloseInfo.Center_Id
         WHERE (CenterInfo.Unit_Id = @UnitId) AND (CenterInfo.IsActive = 1)
             AND (CenterInfo.company_u_id=@company_u_id)
         GROUP BY CenterInfo.Center_Name, CenterInfo.Center_Code,
             CenterInfo.Center_Id, CenterInfo.Center_Id_Format)
    ) t1
    ON t1.Center_Id = DayOpenDayCloseInfo.Center_Id
    WHERE DayOpenDayCloseInfo.IsActive = 0
END
RETURN



问候,


Regards,



这篇关于加入sql的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:12