1
如何解决语法,我想只执行一个select语句根据用户的输入即@id附近有语法错误)'
Create Procedure employee
@id int,
@year int
AS
SELECT
CASE
WHEN @id = 1
THEN (select a.name, b.roles
from employee a
inner join department b on a.id = b.id
where b.years in (@year)
or b.roles is not null)
ELSE
CASE
WHEN @id = 2
THEN (select a.name, b.dayoff
from employee a
inner join department b on a.id = b.id
where b.years in (@year)
or b.dayoff is not null)
谢谢戈登,但替换后,我仍然得到不正确的语法附近THEN。我错过了什么..? –
@kdud。 。 。 Ooops,SQL Server没有'THEN'。我通常在'BEGIN'和'END'之间放置任何语句。 –