0

I am trying to create a procedure in my SQL Server Management Studio.

I wrote this code:

CREATE PROCEDURE [dbo].[InsertBookDetails_Sp]
    @BookName  VARCHAR(100),
    @Author    VARCHAR(100),
    @Publisher VARCHAR(100),
    @Price     DECIMAL(18,2),
    @BookPic   VARBINARY(MAX) = NULL, 
AS
BEGIN 
    SET NOCOUNT ON;

    INSERT INTO BookDetails(BookName, Author, Publisher, Price, BookPic)
    VALUES (@BookName, @Author, @Publisher, @Price, @BookPic)
END

but it shows error

Incorrect syntax near 'As'.
Invalid ObjectName BookDetails
Invalid Column name BookName
Invalid Column name Author
Invalid Column name Publisher
Invalid Column name Price
Invalid Column name BookPic

How to solve this error?

1
  • 5
    Remove the comma before the AS. Commented Jul 4, 2018 at 22:32

1 Answer 1

1

The last parameter should not have ",". Remove the extra "," and try:

CREATE PROCEDURE [dbo].[InsertBookDetails_Sp]
@BookName VARCHAR(100),
@Author VARCHAR(100),
@Publisher VARCHAR(100),
@Price DECIMAL(18, 2),
@BookPic VARBINARY(MAX) = NULL

AS BEGIN SET NOCOUNT ON; INSERT INTO BookDetails (BookName, Author, Publisher, Price, BookPic) VALUES (@BookName, @Author, @Publisher, @Price, @BookPic); END

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.