what is the order of execution of a sql statement with GO statements?

  • Hello,

    Curious if I have the code below as an example and I execute this code does sql execute from top to bottom? And does the Update run and complete before the delete occurs? Or does SQL execute the update and delete in parallel? Appreciate the info.

    UPDATE tbl1 SET col1 = 1

    GO

    DELETE FROM tbl1 where col2 = 2

  • JP10 (1/16/2014)


    Hello,

    Curious if I have the code below as an example and I execute this code does sql execute from top to bottom? And does the Update run and complete before the delete occurs? Or does SQL execute the update and delete in parallel? Appreciate the info.

    UPDATE tbl1 SET col1 = 1

    GO

    DELETE FROM tbl1 where col2 = 2

    Yes, SQL executes from top to bottom, and linearly. There is no multithreading the next command down while the first still processes. GO is used to separate batches in a screen, it's not a command you'd use in, say, a procedure. If anything you'd use it to separate creating procedures so one didn't get folded into the first.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • thank you Evil Kraig!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply