select 2 [@cellpadding] ,2 [@cellspacing] ,1 [@border] -- Creamos Cabecera ,(select th from (select 'ID Cliente' th union all select 'Nombre' union all select 'Apellidos') cualquieralias -- El nombre que le demos no es relevante, pero hace falta poner uno for xml path(''),type) tr -- Definimos la fila de cabecera como un elemento tr -- Devolvemos Filas de la Tabla ,(select (select ID for xml path('td'),type), (select Nombre for xml path('td'),type), (select Apellidos for xml path('td'),type) from dbo.clientes for xml path ('tr'),type) -- Path('tr') para que devuelva cada fila con un elemento tr for xml path('table'), type
Devolver Query como Tabla HTML
Started by Alberto Dominguez, may 18 2011 08:20
No replies to this topic
#1
Escrito 18 mayo 2011 - 08:20
Supongamos que tenemos una tabla dbo.Clientes con ID, Nombre, Apellidos como columnas. Para devolver una query a la misma como tabla html:
Saludos,
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
Alberto Dominguez
Enterprise Architect y Trainer
MCT, MCPD, MCITP, MCITP Dynamics, MCSE, MCSA, MCTS, MCP...
ITIL V3 Foundation Qualification in IT Service Management
Perfil Profesional Twitter
0 usuarios están leyendo este tema
0 miembro/s, 0 invitado/s, 0 usuario/s anónimo/s