有没有办法从表/视图中选择 SELECT 子句中的第 n 列 [英] Is there a way to select nth column in a SELECT clause from a table/view

查看:26
本文介绍了有没有办法从表/视图中选择 SELECT 子句中的第 n 列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个包含数百列的巨大视图,我需要选择第 114 列,例如:

I've this GIGANTIC view with several hundred columns and I need to select 114th column something like:

SELECT "144" FROM MyView;

PS:显然,我不知道该列的名称.我只是将结果行复制到 Excel 文件中,搜索了 EJ 列中的特定值,因此我想选择视图中仅显示第 n 列的所有行以进行进一步调试.

PS: Obviously, I don't know the name of the column. I just copied the results row into an Excel file, searched for a particular value that is in EJ column so I want to select all rows showing only nth column in my view to do my further debugging.

干杯!

推荐答案

如果您使用的是 MS SQL Server,您可以

If you are using MS SQL Server you can

sp_help ViewName

然后滚动到 Column_name 结果集中的第 144 列以查看该列的名称.

and then scroll to the 144th column in the Column_name result set to see what the name of that column is.

此外,您可以在 SQL Server Management Studio 的结果窗格中选择使用标题复制",然后将结果集粘贴到 Excel 中,标题(列名称)保持不变.

Additionally you can choose "Copy with Headers" in the result pane in SQL Server Management Studio and paste the result set into Excel with the headers (column names) intact.

这篇关于有没有办法从表/视图中选择 SELECT 子句中的第 n 列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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