Anna T
Anna T

Reputation: 1027

Execute SQL Server stored procedure with input parameter

Could you suggest please how to execute from Sql Server a stored procedure that receives an input parameter? I tried this but it failed:

EXEC GetFilmsInCategory('SF'); 

The stored procedure is correctly defined, by the way. I executed it from the visual interface and it worked, with this code generated automatically:

DECLARE @return_value int

EXEC @return_value = [dbo].[GetFilmsInCategory] @CatNume = N'SF'

SELECT 'Return Value' = @return_value

I find this automatically generated code too... lengthy as I was expecting something similar to what I initially tried:

EXEC GetFilmsInCategory('SF'); 

Can you fix this or offer an alternative? Thank you!

Anna

Upvotes: 1

Views: 10471

Answers (2)

bluevector
bluevector

Reputation: 3493

You can also address the parameters by name:

EXEC GetFilmsInCategory @CatNume = 'SF'

Upvotes: 3

Jmyster
Jmyster

Reputation: 995

TRY:

EXEC GetFilmsInCategory 'SF'

Upvotes: 6

Related Questions