1

我有一个存储过程

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.

什么是错误,我正在承诺。感谢您的帮助。

4

1 回答 1

5
Set @Category=""

应该

SET @Category=''

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

于 2013-01-24T11:45:11.690 回答