Hi!
I have to say this is a little bit too hermetic for me, but it works.
This is an example of how to transform a SELECT into HTML format.
Notice that it shows how to add color to each cell (td).
This example is priceless.
If you have any doubt, leave a comment.
Good luck!
SET @html =
cast((
select
td=NICK,'',
td=REPLACE(RTRIM(CONVERT(CHAR( 15) , CAST(unit AS MONEY) ,1)),'.00',''), '',
td=RTRIM(CONVERT(CHAR(15) , CAST(sale AS MONEY) ,1)),'',
td=REPLACE(RTRIM(CONVERT(CHAR( 15) , CAST(TICKETS AS MONEY) ,1)),'.00',''), '',
td=REPLACE(RTRIM(CONVERT(CHAR( 15) , CAST(FLUXO AS MONEY) ,1)),'.00',''), '',
td=PA, '',
td=TM, '',
td=CONVER, '',
cast(case when GOAL_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=GOAL_P, '',
cast(case when UNIT_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),UNIT_ LY_DAY_P), '',
cast(case when SALE_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),SALE_ LY_DAY_P ),'',
cast(case when TICKETS_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),TICKE TS_LY_DAY_P), '',
cast(case when FLUXO_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),FLUXO _LY_DAY_P), '',
cast(case when PA_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),PA_ LY_DAY_P), '',
cast(case when TM_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,0),TM_ LY_DAY_P), '',
cast(case when CONVER_LY_DAY_P < 0 then 'red' else 'blue' end as nvarchar(30)) as 'td/@bgcolor',
td=CONVERT(NUMERIC(11,1),CONVE R_LY_DAY_P),''
FROM [table]
WHERE field LIKE '??%'
ORDER BY convert(numeric(11,1),GOAL_P) DESC
FOR XML path('tr'),type) as nvarchar(max))
+'</table>'
Nenhum comentário:
Postar um comentário