Search code examples
sqlsql-serversql-server-2008sql-server-2017sql-server-2019

Edit asterisk symbol into list of column names in SSMS by wildcard expansion


How to change * [asterisk symbol] into list of column names? I can view the list of column names after placing mouse cursor over the *. Is it possible to click-crack on something to change the * into names without running the script an inserting the results into some dbo.temp table?

enter image description here

So the desired results would be:

with A as (select 
 MyColumn1=1 
,MyColumn2=2 
,MyColumn3=3)

select 
 MyColumn1
,MyColumn2
,MyColumn3
from A

Solution

  • Converting * in a cte to column names in Management studio

    • create a table using ... select * into MyTable from A
    • you can drag Object Explorer / Databases / MyDb / Tables / MyTable / Columns into your query
    • or you can use Script table as Select if you prefer column names with []
    • delete MyTable