Reputation: 5
I have created an azure stored procedure to update a column in an azure database table. It takes row IDs in a VARCHAR parameter.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UpdateLastProcessedSugarContacts] @ContactIds VARCHAR(8000)
AS
BEGIN
UPDATE Contact SET LastProcessedSugar=GETDATE() WHERE ID IN (@ContactIds)
ENDGO
When I call this procedure from a logic app that sends comma separated string in the parameter, it doesn't update the rows because I believe that it adds single quotes before and after the input, and ID column is an INTEGER. Is there a way to compare ID column in a stored procedure with IN operator? My input will be like 186,192,193
Upvotes: 0
Views: 780
Reputation: 1269763
If you insist on passing in a comma-delimited list, then split the value:
UPDATE Contact
SET LastProcessedSugar = GETDATE()
WHERE ID IN (SELECT * FROM STRING_SPLIT(@ContactIds, ','));
Upvotes: 0