I need to call a SqlServer stored procedure from python2.7 via pyodbc module with input parameter name.
I tried based on documentation by input parameter order:
cursor.execute('{CALL [SP_NAME](?,?)}',
('value', 'value'))
It works, but I need to pass parameter name of stored procedure because order of stored procedure input parameter always changes. So I need to pass them by name.
cursor.execute('{CALL [SP_NAME](@param1name,@param2name)}',
('value', 'value'))
However this doesn't work. What's the correct syntax?
解决方案
I tested this using the following stored procedure in SQL Server 2008 R2:
CREATE PROCEDURE [dbo].[breakfast]
@person varchar(50) = 'nobody',
@food varchar(50) = 'tofu'
AS
BEGI