Results 1 to 2 of 2

Thread: sp syntax help

  1. #1
    Join Date
    Jun 2006
    Posts
    66

    Unanswered: sp syntax help

    ALTER PROCEDURE [dbo].[spnewp]
    -- Add the parameters for the stored procedure here
    (@p int output)
    AS
    BEGIN

    SET NOCOUNT ON;

    WHILE @p IS NULL
    BEGIN
    SET @p = cast(round((8999998 * Rand() + 1000000), 0) as int)
    IF EXISTS (SELECT * FROM customers WHERE p = @p)
    SET @p = NULL --Not unique
    ELSE
    --Use @NewNumber, it is unique
    END

    select @p


    i'm getting error

    Msg 156, Level 15, State 1, Procedure spnewp, Line 24
    Incorrect syntax near the keyword 'select'.
    Msg 102, Level 15, State 1, Procedure spnewp, Line 26
    Incorrect syntax near 'OFF'.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you're missing an END
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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