首页 > 解决方案 > 将 URL 作为参数传递的 T-SQL 在存储过程中不起作用

问题描述

我有以下两种情况,一种情况有效,另一种情况无效,我不确定出了什么问题。

我想实施的不工作案例:

exec[dbo].[test]
    @Alias          = 'test',
    @Pipeline       = 'testing_',
    @SBU            = 'Test',
    @LoB            = ' Test',
    @SupportChannel = 'Test',
    @Detail         = 'testing personal version',
    @Status         = 0,
    @Error          = ' no error',
    @Debug          = 1

    DECLARE @ReportURL      NVARCHAR(MAX)
    IF @Pipeline = 'testing_' 
        SET @ReportURL = N'https://powerbi.microsoft.com/en-us/'
    IF @Pipeline = 'testing1_' 
        SET @ReportURL = N'https://www.microsoft.com/en-us/'

    DECLARE @SuccessFooter  NVARCHAR(MAX)   = 'results can be found  </br></br>' + 
    '<p><a href="'+@ReportURL+'" style="color: #FFFFFF"> Click here to view reports.</a></p>' 

第二个相同的情况,我直接传递我不想做的 URL,因为我有多个链接传递给该参数。

exec[dbo].[test]
@Alias          = 'test',
@Pipeline       = 'testing_',
@SBU            = 'Test',
@LoB            = ' Test',
@SupportChannel = 'Test',
@Detail         = 'testing personal version',
@Status         = 0,
@Error          = ' no error',
@Debug          = 1

DECLARE @ReportURL      NVARCHAR(MAX)
IF @Pipeline = 'testing_' 
    SET @ReportURL = N'https://powerbi.microsoft.com/en-us/'
IF @Pipeline = 'testing1_' 
    SET @ReportURL = N'https://www.microsoft.com/en-us/'

DECLARE @SuccessFooter  NVARCHAR(MAX)   = 'results can be found </br></br>' + 
'<p><a href="https://powerbi.microsoft.com/en-us/" style="color: #FFFFFF"> Click here to view reports.</a></p>'

有谁知道如何解决这个问题?

我想动态传递链接。如果我通过 testing_ 它应该采用第一个链接,如果我通过 testing1_ 它应该采用第二个链接。

当我执行[dbo].[test]时,这将给我发送一封电子邮件和相应网站的链接

标签: sql-servertsqlssms

解决方案


推荐阅读