SELECT Flashcards
What are the two main roles of the SELECT clause?
- It evaluates expressions that define the attributes in the query’s result and assigns them with aliases if indicated.
- It applies the DISTINCT clause to eliminate duplicates if indicated.
Note: An expression that defines the attribute could simply be the attribute name. By saying “expression that defines the attribute”” that leaves room for simply the name of the attribute or any expression that results in an attribute.
SQL Server 70-461 02-01
Why is using SELECT * considered a bad practice?
- You may send more data than is needed over the network, and this can have a negative impact on the system’s performance.
- If the underlying table definition changes after the query is created, * may no longer include all of the attributes you need.
- By returning more attributes than you really need, you can prevent SQL Server from using what would normally be considered covering indexes in respect to the interesting set of attributes.
SQL Server 70-461 02-01
What is the difference between standard SQL and T–SQL in terms of minimal SELECT query requirements?
In SQL a query must have, at minimum, a SELECT clause and a FROM clause.
In T–SQL, you can have just a SELECT clause. Such a query is as if issued against an imaginary table that has only one row. For example, SELECT 10 AS col1, ‘ABC’ AS col2.
SQL Server 70-461 02-01