Sub query pass through

Posted by SQL and the like on SQL Blogcasts See other posts from SQL Blogcasts or by SQL and the like
Published on Fri, 22 Mar 2013 09:10:14 GMT Indexed on 2013/06/24 16:30 UTC
Read the original article Hit count: 317

Filed under:
|
|
|
Occasionally in forums and on client sites I see conditional subqueries in statements. This is where the developer has decided that it is only necessary to process some data under a certain condition.  By way of example, something like this : Create Procedure GetOrder @SalesOrderId integer, @CountDetails tinyint as Select SOH.salesorderid , case when @CountDetails = 1 then (Select count(*) from Sales.SalesOrderDetail SOD where SOH.SalesOrderID = SOD.SalesOrderID) end from sales.SalesOrderHeader...(read more)

© SQL Blogcasts or respective owner

Related posts about tsql

Related posts about SQLServer