gpt4 book ai didi

sql - 将查询变量传递给MSDB.dbo.sp_Send_DBMail

转载 作者:行者123 更新时间:2023-12-03 08:20:01 26 4
gpt4 key购买 nike

我已经写了一个SQL查询。但这给了我一个错误。

DECLARE @Delimiter Char(1)
SET @Delimiter = CHAR(9)
EXEC MSDB.dbo.sp_Send_DBMail
@profile_name = 'K2MailSetup',
@Recipients='test@xyz.com',
@Subject='Extraction Report',
@Body='Hi',
@Query='set nocount on;
Select Coalesce(replace(replace(A.[type], char(10), ''''), char(13), ''''),'''') as Type,
try_convert(xml, col).value(''(/collection/object/fields/field/value)[1]'', ''varchar(3)'')
from (select col= Coalesce(replace(replace(A.[business_line], char(10), ''''), char(13), ''''),'''')
FROM [EU_OTH_REG].[dbo].[TBL_EU_OTH_TXN_REG_RSDS] A'

错误状态

Msg 102, Level 15, State 1, Line
Incorrect syntax near '/'.

最佳答案

我在这里发现了2个问题。

  1. your subquery is not properly closed
  2. your quotes are not property terminated

Declare @Query as nvarchar(1000) 
Set @Query='set nocount on;
set QUOTED_IDENTIFIER on;
Select try_convert(xml, Coalesce(replace(replace(A.[business_line], char(10), '''''''')
, char(13), ''''''''),''''''''))
.value(''(/collection/object/fields/field/value)[1]'', ''varchar(3)'')
, Coalesce(replace(replace(A.[type], char(10), ''''''''), char(13), ''''''''),'''''''') as [Type]
from [EU_OTH_REG].[dbo].[TBL_EU_OTH_TXN_REG_RSDS] A;'

关于sql - 将查询变量传递给MSDB.dbo.sp_Send_DBMail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58298194/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com