Create Proc Proc_Name
as begin
SELECT 1111 AS sno,'--ALL--' AS RS.branch
UNION
SELECT Rs.Sno,(RS.branch+'-'+RT.[Type] ) AS branch
FROM K_RT_MasterRetailStores Rs
INNER JOIN K_RT_RetailType RT ON RT.sno=RS.[Type]
ORDER BY Rs.Branch
end
我在“。”附近收到错误的语法错误。在SQL服务器中。我无法找出我的错误。请指导我。
答案 0 :(得分:2)
从别名
中删除表名select 1111 as sno, '--ALL--' as branch
^--------------here
答案 1 :(得分:2)
Create Proc Proc_Name
as
begin
select *
from
(select 1111 as sno,'--ALL--' as branch
union
select Rs.Sno, RS.branch + '-' + RT.[Type]
from K_RT_MasterRetailStores Rs
inner join K_RT_RetailType RT on RT.sno = RS.[Type])
order by Branch
end