What is a sub-query? When would you use one?

Answer Posted / mkd

A subquery is a SELECT statement that is nested within
another T-SQL statement. A subquery SELECT statement if
executed independently of the T-SQL statement, in which it
is nested, will return a result set. Meaning a subquery
SELECT statement can standalone and is not depended on the
statement in which it is nested.

Sometimes the criteria for determining which set of records
will be affected by a SELECT, UPDATE, DELETE and/or INSERT
statement cannot be obtained by hard coding the selection
criteria. Occasionally there is a need to use the results
of a SELECT statement to help determine which records are
returned or are affected by a T-SQL statement. When a
SELECT statement is used inside another statement, the
inside SELECT statement is known as a subquery.

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the tcp/ip port on which sql server runs?

631


explain different types of constraints? : Sql server database administration

578


What is single-user mode?

578


Can you tell me about the concept of ER diagrams?

662


How to check status of stored procedure in sql server?

517






Tell me the use of keyword with encryption. Create a store procedure with encryption?

627


Explain the functionalities that views support?

747


Why truncate is ddl command?

584


What is the data type of time?

581


Does the unique constraint create an index?

638


what kind of lan types do you know? : Sql server database administration

579


What is normalization and denormalization in sql server?

589


Explain a differential backup?

640


What do you mean by data manipulation language?

655


Scalability, Availability, Integration with internet, etc.)?

2493