如何获取查询返回的列数计数 [英] how to get count of number of columns returned by a query
本文介绍了如何获取查询返回的列数计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一种情况,我想获取查询返回的列数.
例如
选择 * 来自
(选择 1 as col1, 2 as col2, 3 4 as col4)tab1
它具有 4 列,因此我希望将输出 作为 4
选择 * 来自
(选择 1 as col1, 2 as col2)tab1
它有2列,所以我想输出为2
有没有办法实现这一目标...
任何帮助将不胜感激.
问候,
Gopal
解决方案
而不是在SQL中进行操作,而是通过检查DataTable.Columns.Count
属性在应用程序代码中进行操作.
>
Hi All,
I have a scenario where i want to get the number of columns returned by a query.
For e.g.
select * from
(select 1 as col1, 2 as col2, 3 as col3, 4 as col4) tab1
This has 4 columns so I want output as 4
select * from
(select 1 as col1, 2 as col2) tab1
This has 2 columns so I want output as 2
Is there a way to achieve this ...
Any help would be much appreciated.
Regards,
Gopal
解决方案
Instead of doing it in your SQL, do it in your application code by checking the DataTable.Columns.Count
property.
这篇关于如何获取查询返回的列数计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文