简体   繁体   中英

Azure database - run azure stored procedure from Logic App with parameter

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)
END

GO

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

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, ','));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM