SQL Server: Tips and Tricks - 2 (2017)
How to quickly write Select Query in SQL Server
1) Select all the columns from a table/ View by using *
You can always use Select * from SchemaName.TableName to display data for all the columns from a table or view. When you use * in Select query, it return you all the columns from table or view.
Let's say that if I want to select all the columns from dbo.TotalSale table, I can use below query
2) Drag the Columns Tab to new query
If you would like to get all the column names for your select query, you will open new query window. Then type Select and Drag the Columns Tab under the table to query window. All the columns will be displayed. If you would like to remove few, you can remove.
After dragging the Columns Tab, you will see the column names are added to select.
3) Select Top X Row
Third and easy way to write your select query is, Right click on Table name and then choose Select Top X Rows ( X can be different as per your SSMS option settings). Once you choose it will generate the select query with all the column. You can remove the top x part from select and modify as required.