简体   繁体   English

逻辑应用程序调用 Azure SQL 存储过程传递日期时间参数

[英]Logic App to call Azure SQL stored procedure passing datetime param

I have a simple stored procedure in an Azure SQL database that takes a single param of type datetime :我在 Azure SQL 数据库中有一个简单的存储过程,它采用datetime类型的单个参数:

CREATE PROCEDURE [dbo].[DeleteLogRecs]
    (@pSinceBefore datetime)

I'd like to call this from an Azure Logic App passing a date value of Now -3 days, so I have the following action:我想从 Azure 逻辑应用程序调用它,传递现在 -3 天的日期值,所以我有以下操作:

"Execute_stored_procedure_(V2)": {
                "inputs": {
                    "body": {
                        "pSinceBefore": "@{convertFromUtc(addDays(utcNow(),-3),'GMT Standard Time')}"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sqldw']['connectionId']"
                        }
                    },

My problem is, I get the following error:我的问题是,我收到以下错误:

"status": 400, “状态”:400,
"message": "Error converting data type nvarchar to datetime.\r\nclientRequestId: dbbd2502-899f-4812-a942-4c11bbed4c1b", "message": "将数据类型 nvarchar 转换为 datetime 时出错。\r\nclientRequestId: dbbd2502-899f-4812-a942-4c11bbed4c1b",
"error": { “错误”: {
"message": "Error converting data type nvarchar to datetime." "message": "将数据类型 nvarchar 转换为 datetime 时出错。"

在此处输入图像描述

Can anyone see where I'm going wrong?谁能看到我哪里出错了?

I've managed to bodge this by changing the type of the stored procedure parameter to a string and using the following formatting from the logic app:我设法通过将存储过程参数的类型更改为字符串并使用逻辑应用程序中的以下格式来解决这个问题:

"Execute_stored_procedure_(V2)": {
                "inputs": {
                    "body": {
                        "pSinceBefore": "@{formatDateTime(addDays(utcNow(),-3),'yyyy-MM-dd HH:mm:ss')}"
                    },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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