Reputation: 47
When using select * from dbo.myTable
, is there a way with a join or shortcut to get the column names represented from the wildcard?
Looking for a shorthand use so I don't have to type out 80 column names.
Thanks!
Upvotes: 1
Views: 74
Reputation: 460
here is a script that will work on sql server(assuming that is your vendor as you have dbo in your example)
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
copy and paste the output and enjoy.
Upvotes: 1
Reputation: 123
I use SQLComplete for this..
https://www.devart.com/dbforge/sql/sqlcomplete/
Not quite what you want, but it is an option.
Upvotes: 1