SQL查询在sql server中以HTML格式输出表数据? [英] Sql query to get table data output in HTML format in sql server?

查看:222
本文介绍了SQL查询在sql server中以HTML格式输出表数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sql server中以HTML格式输出表数据的SQL查询?

Sql query to get table data output in HTML format in sql server?

推荐答案

一种方法是可以将数据连接成一个HTML字符串。例如,请查看以下内容:

- http:// www。 sqlservercentral.com/Forums/Topic1351160-338-1.aspx [ ^ ]

- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/10/24/format-query-output-into-an-html- table-the-easy-way.aspx [ ^ ]



但是,在实现格式化之前在数据库方面,考虑是否可以在主叫方进行格式化。



最好不要在查询中格式化结果,而是在调用端进行格式化,例如格式化功能通常要好得多。同样只返回数据通常会使查询更具通用性。
One way is that you can concatenate the data into a one HTML string. For example have a look at the following:
- http://www.sqlservercentral.com/Forums/Topic1351160-338-1.aspx[^]
- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/10/24/format-query-output-into-an-html-table-the-easy-way.aspx[^]

However, before implementing formatting in the database side, consider if you can do the formatting on the calling side.

It's a good practice not to format the result in the query but to do the formatting on the calling side where for example the capability for formatting is often much better. Also just returning the data often makes the query more general-purpose.


这篇关于SQL查询在sql server中以HTML格式输出表数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆