Hi All!
I'm really new to SQL environment in general so, sorry if this is a stupid question.
I'm trying to create a Stored Procedure on my BD with SQL Server Management Studio Express.
I receive this error:
Msg 156, Level 15, State 1, Procedure sprocBlogEntrySelectListByCategory, Line 18
Incorrect syntax near the keyword 'ON'.
This is the sp:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE sprocBlogEntrySelectListByCategory
@.categoryId int
AS
BEGIN
SET NOCOUNT ON;
SELECT
BlogPosts.bp_ID,
BlogPosts.bp_Title,
BlogPosts.bp_Body,
BlogPosts.bp_DatePublished,
Categories.cat_Name
FROM
PostInCategories ON BlogPosts.bp_ID = PostInCategories.bp_ID INNER JOIN
Categories ON PostInCategories.cat_ID = Categories.cat_ID
WHERE
(PostInCategories.cat_ID = @.categoryId)
ORDER BY
BlogPosts.bp_DatePublished DESC
END
GO
I really don't understand this error and what does this means in my case.
Any suggestion is appreciated.
alan
It seems to me that the error is in your FROM clause. FROM must be followed with a table name, derived table, or view.
In your case, you have a FROM clause followed by a JOIN condition without the JOIN clause.
|||I am guessing you mean this:CREATE PROCEDURE sprocBlogEntrySelectListByCategory
@.categoryId int
AS
BEGIN
SET NOCOUNT ON;
SELECT
BlogPosts.bp_ID,
BlogPosts.bp_Title,
BlogPosts.bp_Body,
BlogPosts.bp_DatePublished,
Categories.cat_Name
FROM
PostInCategories
INNER JOIN BlogPosts ON BlogPosts.bp_ID = PostInCategories.bp_ID
INNER JOIN Categories ON PostInCategories.cat_ID = Categories.cat_ID
WHERE
(PostInCategories.cat_ID = @.categoryId)
ORDER BY
BlogPosts.bp_DatePublished DESC
END
hth.
I tryed to re-write the sp in SQL Mgm Studio from scratch.
Identical to that one I posted earlier in my opening, and it was accepted without problem.
I think there was same TAB, SPACE or Comma character wrong.
I think my "issue" is resoved.
Thanks for yuor help anyway
Alan.
No comments:
Post a Comment