Results 1 to 6 of 6

Thread: Stored Error

  1. #1
    Join Date
    Jun 2010
    Posts
    28

    Unanswered: Stored Error

    Hi All

    I cant get my Stored Procedure to work. It has 2 parameters but comes up with the following error message:

    "Msg 102, Level 15, State 1, Procedure spSales, Line 4
    Incorrect syntax near '@PersonName'.
    Msg 137, Level 15, State 2, Procedure spSales, Line 10
    Must declare the scalar variable "@CountryName"."

    Code:
    CREATE PROCEDURE spSales
    
    @CountryName nvarchar(50)
    @PersonName nvarchar(50)
    
    AS
    
    SELECT     Country, Person
    FROM         Table1
    WHERE     (Country = @CountryName) AND (Person = @PersonName)
    Any ideas?

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Wrap your parameters in brackets (parentheses).

  3. #3
    Join Date
    Jun 2010
    Posts
    28
    Quote Originally Posted by pootle flump View Post
    Wrap your parameters in brackets (parentheses).
    Hi

    This doesnt work

    Code:
    CREATE PROCEDURE spSales
    
    (@CountryName) nvarchar(50)
    (@ConsultantName) nvarchar(50)
    
    
    AS
    
    SELECT     Country, Person
    FROM         Table1
    WHERE     (Country = @CountryName) AND (Person = @ConsultantName)


    and this doesnt work... not sure what you mean?

    Code:
    CREATE PROCEDURE spSales
    
    @CountryName nvarchar(50)
    @ConsultantName nvarchar(50)
    
    
    AS
    
    SELECT     Country, Person
    FROM         Table1
    WHERE     Country = (@CountryName) AND Person = (@ConsultantName)

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    CREATE PROCEDURE spSales
    
    (@CountryName nvarchar(50)
    @ConsultantName nvarchar(50))
    AS

  5. #5
    Join Date
    Jun 2010
    Posts
    28
    Quote Originally Posted by pootle flump View Post
    Code:
    CREATE PROCEDURE spSales
    
    (@CountryName nvarchar(50)
    @ConsultantName nvarchar(50))
    AS
    Just did it and doesnt work...any ideas?

    Code:
    CREATE PROCEDURE spSales
    
    (@CountryName nvarchar(50)
    @ConsultantName nvarchar(50))
    
    AS
    
    SELECT     Country, Person
    FROM         Table1
    WHERE     (Country = @CountryName) AND (Person = @ConsultantName)

  6. #6
    Join Date
    Jun 2010
    Posts
    28
    Quote Originally Posted by pootle flump View Post
    Code:
    CREATE PROCEDURE spSales
    
    (@CountryName nvarchar(50)
    @ConsultantName nvarchar(50))
    AS
    Hi

    Just found out... it needed a comma ","

    Code:
    @CountryName nvarchar(50),
    @ConsultantName nvarchar(50)
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •