在Sql Server 2005上创建过程错误 [英] Creating Procedure on Sql Server 2005 error
本文介绍了在Sql Server 2005上创建过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,程序员在这里遇到了一些问题.如您所见,我正在尝试创建一个过程(在这方面是新的),但出现错误,提示
Hello programmers, got a few problems here. As you see I am trying to create A procedure (New on this stuff) but got an error saying
Msg 102, Level 15, State 1, Procedure GetAllCoursesAndCategories, Line 3<br />
Incorrect syntax near ''@CourseCatID''.<br />
Msg 137, Level 15, State 2, Procedure GetAllCoursesAndCategories, Line 18<br />
Must declare the scalar variable "@Year".
主席先生,这有什么问题?请帮助..谢谢和更多的力量
Sir what is the problem regarding that? Please help.. Thanks and more power
CREATE PROCEDURE GetAllCoursesAndCategories
@Year varchar(128)
@CourseCatID int
AS
BEGIN
Select Crse.CourseName, CrseYr.CourseCode ,CrseYr.CourseDuration
from TrainingPlanTemplate temp
Inner Join Course Crse On
temp.CourseID = Crse.CourseID
Inner Join CourseCategory CrseCat On
temp.CourseCatID = CrseCat.CourseCatID
Inner Join CourseYear CrseYr On
temp.Year = CrseYr.Year
Inner Join CourseCatYear CrseCtYr On
temp.Year = CrseCtYr.Year
Where
temp.Year = @Year And
temp.CourseCatID = @CourseCatID
END
GO
推荐答案
我认为您忘了在第二行加上逗号.更改第1,2&行3以下:
I think you forgot to put a comma on the second line. Change lines 1,2 & 3 with the following:
CREATE PROCEDURE GetAllCoursesAndCategories
@Year varchar(128),
@CourseCatID int
CREATE PROCEDURE GetAllCoursesAndCategories
@Year varchar(128)
@CourseCatID int
AS
用上面的代码替换上面的代码
replace the above code with this one
CREATE PROCEDURE GetAllCoursesAndCategories
{
@Year varchar(128),
@CourseCatID int
}
AS
通过这些链接,您可以了解有关sql server中过程的更多信息
检查此链接
http://msdn.microsoft.com/en-us/library/aa258259 (v = sql.80).aspx
最好的
Hi,
You can learn much about procedures in sql server through these links
check this link
http://msdn.microsoft.com/en-us/library/aa258259(v=sql.80).aspx
All the Best
这篇关于在Sql Server 2005上创建过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文