Formating color in SQL Server using FOR XML PATH

前端 未结 3 1341
时光说笑
时光说笑 2021-01-24 23:48

I already used this method, but now I have to use some colors depending on the values. So, I have the following information in a table:

Material | Q1 | Q2
------         


        
3条回答
  •  长发绾君心
    2021-01-25 00:05

    How about something like this.

    CREATE TABLE #tempo(
    q1 INT, q2 INT, name VARCHAR(10)
    )
    
    INSERT INTO #tempo(q1,q2,name)VALUES(10,5,'low')
    INSERT INTO #tempo(q1,q2,name)VALUES(10,10,'same')
    INSERT INTO #tempo(q1,q2,name)VALUES(10,20,'high')
    
    DECLARE @html varchar(MAX) = ''
    
    SELECT @html = @html + ''
    FROM #tempo
    
    select @html = @html + '
    q1 q2 Compare
    ' + convert(varchar(10), q1) + '' + convert(varchar(10), q2) + '
    ' select @html DROP TABLE #tempo

提交回复
热议问题