SQL Procedure has no parameters and arguments were supplied
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
add a comment |
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
Side note: you should not use thesp_
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 avoidsp_
and use something else as a prefix - or no prefix at all!
– marc_s
Dec 4 '16 at 21:18
add a comment |
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
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
sql-server stored-procedures execute
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 thesp_
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 avoidsp_
and use something else as a prefix - or no prefix at all!
– marc_s
Dec 4 '16 at 21:18
add a comment |
Side note: you should not use thesp_
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 avoidsp_
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
add a comment |
3 Answers
3
active
oldest
votes
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
add a comment |
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).
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
edited Dec 4 '16 at 21:11
answered Dec 4 '16 at 21:05
MattMatt
10.4k11026
10.4k11026
add a comment |
add a comment |
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).
add a comment |
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).
add a comment |
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).
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).
answered Mar 2 '17 at 17:57
Meghan KothariMeghan Kothari
111
111
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 14 '18 at 11:47
AmjadAmjad
113
113
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 avoidsp_
and use something else as a prefix - or no prefix at all!– marc_s
Dec 4 '16 at 21:18