Execute SQL Server stored procedure with input parameter

不羁岁月 提交于 2020-01-06 02:00:26

问题


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


回答1:


TRY:

EXEC GetFilmsInCategory 'SF'



回答2:


You can also address the parameters by name:

EXEC GetFilmsInCategory @CatNume = 'SF'


来源:https://stackoverflow.com/questions/10806397/execute-sql-server-stored-procedure-with-input-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!