繁体   English   中英

使用通配符从查询中获取列名

[英]Obtain column names from query using wildcard

当使用select * from dbo.myTable ,是否可以select * from dbo.myTable或快捷方式来获取通配符表示的列名?

寻找速记用途,因此我不必键入80列名称。

谢谢!

我为此使用SQLComplete。

https://www.devart.com/dbforge/sql/sqlcomplete/

并不是您想要的,但这是一个选择。

这是一个可以在sql服务器上运行的脚本(假设您的供应商是您的示例中的dbo)

declare @table as varchar(max) = 'spt_monitor' -- replace this with your table

select 'select ' +  stuff((SELECT ', ' + column_name
FROM information_schema.columns
WHERE table_name = @table for xml path('')),1,1,'')  + ' from ' + @table 

复制并粘贴输出并享受。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM