0

I need to execute a stored procedure from Python. I am using pyodbc to do that. The stored procedure requires a datetime parameter to be passed.

I am using the below code:

cursor.execute('exec [Data].[GetData]?',datetime.datetime.now()) 

I get the following error:

ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type datetime to bigint is not allowed. Use the CONVERT function to run this query. (257) (SQLExecDirectW)')

What should I do ?

1
  • 1
    "The SP requires a datetime parameter to be passed" - The error message suggests otherwise. It appears to be expecting a bigint value. Check the documentation for the stored procedure to verify what the parameter value really should be. Commented Apr 9, 2019 at 13:48

1 Answer 1

1
from datetime import datetime cursor.execute('exec [Data].[GetData]?',datetime.now()) 

had the same error check your import

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.