如何从SQL Server中提取列名 [英] How do I extract column name from SQL server

查看:272
本文介绍了如何从SQL Server中提取列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sql server中有数据库表,其中一些列是从S1串行定位的位字段。 No. 6到13.

现在我想从Sl中提取表的列名。第6至13号是真实的,并留下所有不正确的,即假的。





请建议我数据库查询目的。



我的尝试:



如何提取真位字段的列名

解决方案

这实际上是不可能的:它要求返回的数据中每一行返回的列数不同,并且SQL就是没有为此设置的。

你可以通过将列名转换为逗号分隔列表来实现,但是......这样做很难,但仍然需要用您的演示语言进行后续处理。

因此,我强烈建议您返回所有列,然后使用演示语言处理它,而不是在这里处理复杂的SQL。 / blockquote>

那么,我们如何用逗号分隔的普通文本显示相同的内容。?



请详细说明


I have database table in sql server in which some columns are bit fields which serially located from Sl. No. 6 to 13.
Now I want to extract the column name of the table from Sl. No. 6 to 13 which are true and leave all which are not true i.e. false.


Please suggest me the database query for the purpose.

What I have tried:

How to extract the column names for true bit fields

解决方案

That isn't really possible: it would require that the number of columns returned was different for each row in the returned data, and SQL just isn't set up for that.
You could do it, by converting the column names to a comma delimited list, but ... it'd be nasty to do, and would still require subsequent processing in your presentation language.
As a result, I'd strongly suggest that you returned all the columns and just process it in the presentation language instead of faffing about with complicated SQL at all here.


So, how can we show the same in comma separated normal text.?

please explain the same in detail


这篇关于如何从SQL Server中提取列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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