Ramco Ramco

Ramco Ramco

  • 438
  • 3.4k
  • 542.2k

Color column

Aug 16 2023 3:32 AM

Hi

  I have below code I want if AcctCode is '10011' its color should be red

ALTER PROCEDURE sp_color
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
    SET NOCOUNT ON;

    DECLARE @body NVARCHAR(MAX)
    SET @body = N'<table>'
               + N'<tr><th>AcctCode</th><th>AcctName</th></tr>'
               + CAST((
                   SELECT  p.AcctCode AS td,
                           p.AcctName AS td
                   FROM    Oact p
                   FOR XML RAW('tr'), ELEMENTS
               ) AS NVARCHAR(MAX))
               + N'</table>'

    -- Return the generated HTML content
    SELECT @body AS HtmlContent
END
GO

Thanks 


Answers (6)