小编Chu*_*yTM的帖子

如何在Transact-SQL中设置参数时连接字符串

这里的第一个问题是以下.我写了下面的代码,一切正常:

DECLARE @subject NVARCHAR(100)
SET @subject = 'Report executed on ' + CONVERT(VARCHAR(12), GETDATE(), 107)
SELECT @subject
Run Code Online (Sandbox Code Playgroud)

结果:报告于2012年8月17日执行

但是在设置msdb.dbo.sp_send_dbmail过程的参数时尝试连接前一个字符串时,它会失败

EXEC msdb.dbo.sp_send_dbmail @profile_name='XXX',
@recipients='XXXX@XXXXX.com',
@subject = 'Report executed on ' + CONVERT(VARCHAR(12), GETDATE(), 107),
@body= @tableHTML,
@body_format = 'HTML';
Run Code Online (Sandbox Code Playgroud)

我知道我可以声明并向参数发送一个变量,但我想了解为什么它在参数中直接连接时失败了.谢谢你的时间和知识

t-sql sql-server

20
推荐指数
2
解决办法
4万
查看次数

如何使用XQuery将连续标记转换为嵌套标记或表

我有一个带有连续标签的XML文件,而不是嵌套标签,如下所示:

<title>
    <subtitle>
        <topic att="TopicTitle">Topic title 1</topic>
        <content att="TopicSubtitle">topic subtitle 1</content>
        <content att="Paragraph">paragraph text 1</content>
        <content att="Paragraph">paragraph text 2</content>
        <content att="TopicSubtitle">topic subtitle 2</content>
        <content att="Paragraph">paragraph text 1</content>
        <content att="Paragraph">paragraph text 2</content>

        <topic att="TopicTitle">Topic title 2</topic>
        <content att="TopicSubtitle">topic subtitle 1</content>
        <content att="Paragraph">paragraph text 1</content>
        <content att="Paragraph">paragraph text 2</content>
        <content att="TopicSubtitle">topic subtitle 2</content>
        <content att="Paragraph">paragraph text 1</content>
        <content att="Paragraph">paragraph text 2</content>
    </subtitle>
</title>
Run Code Online (Sandbox Code Playgroud)

我在BaseX中使用XQuery,我想将其转换为包含以下列的表:

Title      Subtitle      TopicTitle      TopicSubtitle      Paragraph
Irrelevant Irrelevant    Topic title 1   Topic Subtitle 1   paragraph text 1
Irrelevant Irrelevant …
Run Code Online (Sandbox Code Playgroud)

xml xpath xquery xquery-3.0

0
推荐指数
1
解决办法
142
查看次数

标签 统计

sql-server ×1

t-sql ×1

xml ×1

xpath ×1

xquery ×1

xquery-3.0 ×1