SQL Query Order of Execution
-
Hi All, Can anyone tell me the order in which sql Query executes Example: select C.*,RenewalDate=(select * From CustomerApprovals where CustNo=1 Order By ApprovalDate Desc) from Customers C where C.CustNo=1
N.Rajakumar B.E., Application Developer, www.newdreamz.tk
-
Hi All, Can anyone tell me the order in which sql Query executes Example: select C.*,RenewalDate=(select * From CustomerApprovals where CustNo=1 Order By ApprovalDate Desc) from Customers C where C.CustNo=1
N.Rajakumar B.E., Application Developer, www.newdreamz.tk
All at once - SQL is a set based language not a procedural language, although for certain things you can act in a procedural manner (e.g. using cursors) but this is slow because it is not using the strengths of the language. Basically a SELECT statement is telling SQL Server what you want, and then SQL Server figures out itself how to achive the result you want. If it makes it any easier for you to think about you can think of the subquery executing first. However, the reality is that many parts of the query will execute in parallel. Aside from that I cannot see what you are tying to do with your statement because it is invalid.
* Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
-
Hi All, Can anyone tell me the order in which sql Query executes Example: select C.*,RenewalDate=(select * From CustomerApprovals where CustNo=1 Order By ApprovalDate Desc) from Customers C where C.CustNo=1
N.Rajakumar B.E., Application Developer, www.newdreamz.tk
Look at the execution plan to see the order in which it will be executed.
A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane