Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Query Order of Execution

SQL Query Order of Execution

Scheduled Pinned Locked Moved Database
databasetutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajkamal_dfine
    wrote on last edited by
    #1

    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

    C E 2 Replies Last reply
    0
    • R Rajkamal_dfine

      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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • R Rajkamal_dfine

        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

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups