filmov
tv
How to quickly write Select Query in SQL Server- SQL Server / TSQL Tutorial Part 108
Показать описание
SQL Server / T-SQL Tutorial Scenario:
How to quickly write Select Query in SQL Server - SQL Server / TSQL Tutorial
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.
Link to scripts used in SQL Server / TSQL Tutorial Video
Check out our website for Different SQL Server, MSBI tutorials and interview questions
such as SQL Server Reporting Services(SSRS) Tutorial
SQL Server Integration Services(SSIS) Tutorial
SQL Server DBA Tutorial
SQL Server / TSQL Tutorial ( Beginner to Advance)
How to quickly write Select Query in SQL Server - SQL Server / TSQL Tutorial
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.
Link to scripts used in SQL Server / TSQL Tutorial Video
Check out our website for Different SQL Server, MSBI tutorials and interview questions
such as SQL Server Reporting Services(SSRS) Tutorial
SQL Server Integration Services(SSIS) Tutorial
SQL Server DBA Tutorial
SQL Server / TSQL Tutorial ( Beginner to Advance)