xorsyst
xorsyst

Reputation: 8257

Can you pass table input parameter to SQL Server from Python

MS SQL Server supports passing a table as a stored-procedure parameter. Is there any way to utilize this from Python, using PyODBC or pymssql?

Upvotes: 1

Views: 941

Answers (2)

xorsyst
xorsyst

Reputation: 8257

Use IronPython. It allows direct access to the .net framework, and therefore you can build a DataTable object and pass it over.

Upvotes: 0

Dan Field
Dan Field

Reputation: 21661

There may be a way to do so using a more API-ey feature, but if all else fails you could just use whatever the API exposes to send raw SQL commands to build the tables yourself and call the procedure, using a query string like the following:

DECLARE @p1 <TableTypeName>;
INSERT @p1 VALUES (<value list...>);    
EXEC usp_Procedure @p1;

Upvotes: 4

Related Questions