存储过程出错

时间:2013-01-24 11:43:37

标签: sql-server-2008 stored-procedures

我有一个存储过程

Create proc [dbo].[DNNCentric_TechAnyClass_Course_FilterByCategory]
@CategoryName nvarchar(350)='Business'
AS
BEGIN
Declare @Category nvarchar(350)
Set @Category=""
if(@CategoryName='Business')
begin
  Set @Category=@CategoryName
end
select Course.CourseId,Course.CourseTitle,Course.CourseDescription,Category.CategoryName,FormatMaster.FormatType,Teacher.TeacherName
From dbo.DNNCentric_TechAnyClass_CategoryMaster As Category 
     Inner Join dbo.DNNCentric_TechAnyClass_Course As Course ON Category.CategoryID = Course.CategoryId
     Inner Join dbo.DNNCentric_TechAnyClass_FormatMaster As FormatMaster ON FormatMaster.FormatID = Course.FormatID
     Inner Join dbo.DNNCentric_TechAnyClass_Teacher As Teacher ON Teacher.TeacherId=Course.TeacherId
Where    Category.CategoryName=@Category 
END

显示错误为

Msg 1038, Level 15, State 4, Procedure DNNCentric_TechAnyClass_Course_FilterByCategory, Line 6
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

错误是什么,我正在提交。谢谢你的帮助。

1 个答案:

答案 0 :(得分:5)

Set @Category=""

应该是

SET @Category=''

双引号(“)应该是撇号(')