从存储过程的结果中按行检索列名 [英] Retrieve Column Names from a result of Stored Procedure in row wise

查看:91
本文介绍了从存储过程的结果中按行检索列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我有一个存储过程..我想要该存储过程的结果数据的列名
这是我的要求.


exec sp_empdetails 1

empno empname工资
----------------------
1 abc 10000

我想要连续的列标题

columnNames
-----------
empno
empname
工资

Hi..

I have a stored procedure ..I want column names of the result data of that stored procedure
Here is my Requirement..


exec sp_empdetails 1

empno empname salary
----------------------
1 abc 10000

I want the column headings in a row wise

columnNames
-----------
empno
empname
salary

推荐答案

在下面的查询中使用以获取特定表中列的列表(按行)
information_schema.columns
use below query to get list of columns(Row-wise) in particlar table
select column_name from information_schema.columns
where table_name='TableName'


祝您编码愉快!
:)


Happy Coding!
:)


您未指定要使用的语言.如果使用的是.Net,请使用sqldataadapter填充数据表.

假设您填充了名为"dtbl"的数据表
这是代码
You didn''t specify which language you are using. If you are using .Net, fill the datatable using sqldataadapter.

Suppose, you filled up the datatable named "dtbl"
Here is the code
foreach (DataColumn col in dtbl.Columns)
{
  //col.Caption
  //col.DataType
  //col.ColumnName
}



欢呼



cheers


这篇关于从存储过程的结果中按行检索列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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