SQL Procedure has no parameters and arguments were supplied










1















So here is the code for the stored procedure and my execution. I keep getting this message when I try to execute my command:




Msg 8146, Level 16, State 2, Procedure sp_LabelFilm, Line 0

Procedure sp_LabelFilm has no parameters and arguments were supplied.




Any idea why? I am trying to update a column in the table tblfilm to say if a movie is short, medium, or long based on its run time.



ALTER PROCEDURE [dbo].[sp_LabelFilm]
AS
BEGIN
DECLARE @Minutes INT, @duration char(10)

DECLARE Filmcursor CURSOR FOR
(SELECT filmruntimeminutes, Duration FROM tblFilm)

OPEN filmcursor

FETCH NEXT FROM filmcursor INTO @duration

WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @Minutes = FilmRunTimeMinutes FROM tblFilm

IF @Minutes < 120
SET @duration = 'short'
ELSE IF @Minutes < 150
SET @duration = 'medium'
ELSE
SET @duration = 'long'

FETCH NEXT FROM filmcursor INTO @duration

UPDATE tblFilm
SET Duration = @duration
END

CLOSE filmcursor
DEALLOCATE filmcursor
END



DECLARE @Minutes INT, @duration CHAR(10)

EXECUTE [dbo].[sp_LabelFilm] @minutes, @duration









share|improve this question
























  • Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

    – marc_s
    Dec 4 '16 at 21:18















1















So here is the code for the stored procedure and my execution. I keep getting this message when I try to execute my command:




Msg 8146, Level 16, State 2, Procedure sp_LabelFilm, Line 0

Procedure sp_LabelFilm has no parameters and arguments were supplied.




Any idea why? I am trying to update a column in the table tblfilm to say if a movie is short, medium, or long based on its run time.



ALTER PROCEDURE [dbo].[sp_LabelFilm]
AS
BEGIN
DECLARE @Minutes INT, @duration char(10)

DECLARE Filmcursor CURSOR FOR
(SELECT filmruntimeminutes, Duration FROM tblFilm)

OPEN filmcursor

FETCH NEXT FROM filmcursor INTO @duration

WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @Minutes = FilmRunTimeMinutes FROM tblFilm

IF @Minutes < 120
SET @duration = 'short'
ELSE IF @Minutes < 150
SET @duration = 'medium'
ELSE
SET @duration = 'long'

FETCH NEXT FROM filmcursor INTO @duration

UPDATE tblFilm
SET Duration = @duration
END

CLOSE filmcursor
DEALLOCATE filmcursor
END



DECLARE @Minutes INT, @duration CHAR(10)

EXECUTE [dbo].[sp_LabelFilm] @minutes, @duration









share|improve this question
























  • Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

    – marc_s
    Dec 4 '16 at 21:18













1












1








1








So here is the code for the stored procedure and my execution. I keep getting this message when I try to execute my command:




Msg 8146, Level 16, State 2, Procedure sp_LabelFilm, Line 0

Procedure sp_LabelFilm has no parameters and arguments were supplied.




Any idea why? I am trying to update a column in the table tblfilm to say if a movie is short, medium, or long based on its run time.



ALTER PROCEDURE [dbo].[sp_LabelFilm]
AS
BEGIN
DECLARE @Minutes INT, @duration char(10)

DECLARE Filmcursor CURSOR FOR
(SELECT filmruntimeminutes, Duration FROM tblFilm)

OPEN filmcursor

FETCH NEXT FROM filmcursor INTO @duration

WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @Minutes = FilmRunTimeMinutes FROM tblFilm

IF @Minutes < 120
SET @duration = 'short'
ELSE IF @Minutes < 150
SET @duration = 'medium'
ELSE
SET @duration = 'long'

FETCH NEXT FROM filmcursor INTO @duration

UPDATE tblFilm
SET Duration = @duration
END

CLOSE filmcursor
DEALLOCATE filmcursor
END



DECLARE @Minutes INT, @duration CHAR(10)

EXECUTE [dbo].[sp_LabelFilm] @minutes, @duration









share|improve this question
















So here is the code for the stored procedure and my execution. I keep getting this message when I try to execute my command:




Msg 8146, Level 16, State 2, Procedure sp_LabelFilm, Line 0

Procedure sp_LabelFilm has no parameters and arguments were supplied.




Any idea why? I am trying to update a column in the table tblfilm to say if a movie is short, medium, or long based on its run time.



ALTER PROCEDURE [dbo].[sp_LabelFilm]
AS
BEGIN
DECLARE @Minutes INT, @duration char(10)

DECLARE Filmcursor CURSOR FOR
(SELECT filmruntimeminutes, Duration FROM tblFilm)

OPEN filmcursor

FETCH NEXT FROM filmcursor INTO @duration

WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @Minutes = FilmRunTimeMinutes FROM tblFilm

IF @Minutes < 120
SET @duration = 'short'
ELSE IF @Minutes < 150
SET @duration = 'medium'
ELSE
SET @duration = 'long'

FETCH NEXT FROM filmcursor INTO @duration

UPDATE tblFilm
SET Duration = @duration
END

CLOSE filmcursor
DEALLOCATE filmcursor
END



DECLARE @Minutes INT, @duration CHAR(10)

EXECUTE [dbo].[sp_LabelFilm] @minutes, @duration






sql-server stored-procedures execute






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 '16 at 21:17









marc_s

580k13011191267




580k13011191267










asked Dec 4 '16 at 20:57









Jon DoeJon Doe

12127




12127












  • Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

    – marc_s
    Dec 4 '16 at 21:18

















  • Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

    – marc_s
    Dec 4 '16 at 21:18
















Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

– marc_s
Dec 4 '16 at 21:18





Side note: you should not use the sp_ prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoid sp_ and use something else as a prefix - or no prefix at all!

– marc_s
Dec 4 '16 at 21:18












3 Answers
3






active

oldest

votes


















8














the error means exactly what it says. That you are passing arguments (variables @minutes and @duration) but there are no parameters defined on the stored procedure.



To declare parameters (input variables) you actually declare them before the AS like so:



use Movies
go

alter PROC [dbo].[sp_LabelFilm]
@Minutes INT
,@duration CHAR(10)
AS

BEGIN


DECLARE Filmcursor CURSOR
......


Notice you don't need to use the key word DECLARE and once they are a declared as parameters you don't actually need to declare them again.



Next I am not totally sure what you are attempting to accomplish with the parameters in the stored procedure but it actually looks like you don't want to pass them but rather you want to get them as out put which would be like this:



use Movies
go

alter PROC [dbo].[sp_LabelFilm]
@Minutes INT OUTPUT
,@duration CHAR(10) OUTPUT
AS

BEGIN


DECLARE Filmcursor CURSOR
....


And your execution statement would look like this:



declare @Minutes INT, @duration char(10)
execute [dbo].[sp_LabelFilm] @minutes = @Minutes OUTPUT, @duration = @duration OUTPUT





share|improve this answer
































    1














    I had defined the parameters on the stored procedure, before the AS, but still I was facing the same problem until I realized that the procedure had 'create' instead of 'alter'. Changing it to alter procedure worked for me.(Faced this issue while I was trying to debug).






    share|improve this answer






























      0














      Apart from the first answer which is apt - In my case I did not have any parameters and while EXEC was getting a similar error.



      However the difference being - I was putting a "go" below the EXEC statement.



      After removing the go it was executed properly.






      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40963561%2fsql-procedure-has-no-parameters-and-arguments-were-supplied%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        8














        the error means exactly what it says. That you are passing arguments (variables @minutes and @duration) but there are no parameters defined on the stored procedure.



        To declare parameters (input variables) you actually declare them before the AS like so:



        use Movies
        go

        alter PROC [dbo].[sp_LabelFilm]
        @Minutes INT
        ,@duration CHAR(10)
        AS

        BEGIN


        DECLARE Filmcursor CURSOR
        ......


        Notice you don't need to use the key word DECLARE and once they are a declared as parameters you don't actually need to declare them again.



        Next I am not totally sure what you are attempting to accomplish with the parameters in the stored procedure but it actually looks like you don't want to pass them but rather you want to get them as out put which would be like this:



        use Movies
        go

        alter PROC [dbo].[sp_LabelFilm]
        @Minutes INT OUTPUT
        ,@duration CHAR(10) OUTPUT
        AS

        BEGIN


        DECLARE Filmcursor CURSOR
        ....


        And your execution statement would look like this:



        declare @Minutes INT, @duration char(10)
        execute [dbo].[sp_LabelFilm] @minutes = @Minutes OUTPUT, @duration = @duration OUTPUT





        share|improve this answer





























          8














          the error means exactly what it says. That you are passing arguments (variables @minutes and @duration) but there are no parameters defined on the stored procedure.



          To declare parameters (input variables) you actually declare them before the AS like so:



          use Movies
          go

          alter PROC [dbo].[sp_LabelFilm]
          @Minutes INT
          ,@duration CHAR(10)
          AS

          BEGIN


          DECLARE Filmcursor CURSOR
          ......


          Notice you don't need to use the key word DECLARE and once they are a declared as parameters you don't actually need to declare them again.



          Next I am not totally sure what you are attempting to accomplish with the parameters in the stored procedure but it actually looks like you don't want to pass them but rather you want to get them as out put which would be like this:



          use Movies
          go

          alter PROC [dbo].[sp_LabelFilm]
          @Minutes INT OUTPUT
          ,@duration CHAR(10) OUTPUT
          AS

          BEGIN


          DECLARE Filmcursor CURSOR
          ....


          And your execution statement would look like this:



          declare @Minutes INT, @duration char(10)
          execute [dbo].[sp_LabelFilm] @minutes = @Minutes OUTPUT, @duration = @duration OUTPUT





          share|improve this answer



























            8












            8








            8







            the error means exactly what it says. That you are passing arguments (variables @minutes and @duration) but there are no parameters defined on the stored procedure.



            To declare parameters (input variables) you actually declare them before the AS like so:



            use Movies
            go

            alter PROC [dbo].[sp_LabelFilm]
            @Minutes INT
            ,@duration CHAR(10)
            AS

            BEGIN


            DECLARE Filmcursor CURSOR
            ......


            Notice you don't need to use the key word DECLARE and once they are a declared as parameters you don't actually need to declare them again.



            Next I am not totally sure what you are attempting to accomplish with the parameters in the stored procedure but it actually looks like you don't want to pass them but rather you want to get them as out put which would be like this:



            use Movies
            go

            alter PROC [dbo].[sp_LabelFilm]
            @Minutes INT OUTPUT
            ,@duration CHAR(10) OUTPUT
            AS

            BEGIN


            DECLARE Filmcursor CURSOR
            ....


            And your execution statement would look like this:



            declare @Minutes INT, @duration char(10)
            execute [dbo].[sp_LabelFilm] @minutes = @Minutes OUTPUT, @duration = @duration OUTPUT





            share|improve this answer















            the error means exactly what it says. That you are passing arguments (variables @minutes and @duration) but there are no parameters defined on the stored procedure.



            To declare parameters (input variables) you actually declare them before the AS like so:



            use Movies
            go

            alter PROC [dbo].[sp_LabelFilm]
            @Minutes INT
            ,@duration CHAR(10)
            AS

            BEGIN


            DECLARE Filmcursor CURSOR
            ......


            Notice you don't need to use the key word DECLARE and once they are a declared as parameters you don't actually need to declare them again.



            Next I am not totally sure what you are attempting to accomplish with the parameters in the stored procedure but it actually looks like you don't want to pass them but rather you want to get them as out put which would be like this:



            use Movies
            go

            alter PROC [dbo].[sp_LabelFilm]
            @Minutes INT OUTPUT
            ,@duration CHAR(10) OUTPUT
            AS

            BEGIN


            DECLARE Filmcursor CURSOR
            ....


            And your execution statement would look like this:



            declare @Minutes INT, @duration char(10)
            execute [dbo].[sp_LabelFilm] @minutes = @Minutes OUTPUT, @duration = @duration OUTPUT






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 4 '16 at 21:11

























            answered Dec 4 '16 at 21:05









            MattMatt

            10.4k11026




            10.4k11026























                1














                I had defined the parameters on the stored procedure, before the AS, but still I was facing the same problem until I realized that the procedure had 'create' instead of 'alter'. Changing it to alter procedure worked for me.(Faced this issue while I was trying to debug).






                share|improve this answer



























                  1














                  I had defined the parameters on the stored procedure, before the AS, but still I was facing the same problem until I realized that the procedure had 'create' instead of 'alter'. Changing it to alter procedure worked for me.(Faced this issue while I was trying to debug).






                  share|improve this answer

























                    1












                    1








                    1







                    I had defined the parameters on the stored procedure, before the AS, but still I was facing the same problem until I realized that the procedure had 'create' instead of 'alter'. Changing it to alter procedure worked for me.(Faced this issue while I was trying to debug).






                    share|improve this answer













                    I had defined the parameters on the stored procedure, before the AS, but still I was facing the same problem until I realized that the procedure had 'create' instead of 'alter'. Changing it to alter procedure worked for me.(Faced this issue while I was trying to debug).







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 2 '17 at 17:57









                    Meghan KothariMeghan Kothari

                    111




                    111





















                        0














                        Apart from the first answer which is apt - In my case I did not have any parameters and while EXEC was getting a similar error.



                        However the difference being - I was putting a "go" below the EXEC statement.



                        After removing the go it was executed properly.






                        share|improve this answer



























                          0














                          Apart from the first answer which is apt - In my case I did not have any parameters and while EXEC was getting a similar error.



                          However the difference being - I was putting a "go" below the EXEC statement.



                          After removing the go it was executed properly.






                          share|improve this answer

























                            0












                            0








                            0







                            Apart from the first answer which is apt - In my case I did not have any parameters and while EXEC was getting a similar error.



                            However the difference being - I was putting a "go" below the EXEC statement.



                            After removing the go it was executed properly.






                            share|improve this answer













                            Apart from the first answer which is apt - In my case I did not have any parameters and while EXEC was getting a similar error.



                            However the difference being - I was putting a "go" below the EXEC statement.



                            After removing the go it was executed properly.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 14 '18 at 11:47









                            AmjadAmjad

                            113




                            113



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40963561%2fsql-procedure-has-no-parameters-and-arguments-were-supplied%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Use pre created SQLite database for Android project in kotlin

                                Darth Vader #20

                                Ondo