'Python - Pass UniqueIntList datatype as parameter while calling procedure in MS SQL
I need to execute a procedure from python as below
DECLARE
@LayoutID INT = 9
,@PrivateFL INT =0
,@FromDate DATETIME = '20100101'
,@ToDate DATETIME = '20211001'
,@VesselIDs dbo.UniqueIntList
insert into @VesselIDs values (202),(330)
EXEC usp_GetComments @LayoutID, @PrivateFL, @FromDate, @ToDate, @VesselIDs
How do i pass '@VesselIDs' as parameter while executing it using python?
I tried below but its not working
list = [202,330]
storedProc = "EXEC usp_GetComments @LayoutID=?, @PrivateFL=?, @FromDate=?, @ToDate=?, @VesselIDs=?"
params = (9,0,'20100101','20211001',list)
Solution 1:[1]
Do as below:
storedProc = "EXEC usp_GetComments @LayoutID=?, @PrivateFL=?, @FromDate=?, @ToDate=?, @VesselIDs=?"
fktvp = [(202,),(330,)]
fkparams = (9,0,'20100101','20211001',fktvp)
cursor.execute( storedProc, fkparams )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cristik |
