How to calculate the Bi-weekly in SQL

  • Christian Buettner (12/29/2008)


    RBarryYoung (12/28/2008)


    Christian Buettner (12/28/2008)


    I might be nitpicking here again, but the semicolon is required after the preceding statement, not before the WITH statement.

    Of course the end result is a semicolon between the two statements, but I want to emphasize again that the semicolon ENDs a statement and does not START a statement.

    Ah, and can you describe what the difference is between these two things?

    ๐Ÿ™‚

    I am not sure what your intention is here, but the difference is where the terminator is located.

    And the problem with your claim that semicolon is a statement terminator is that it does not matter whether the ";" is immediately at the end of the preceding statement or immediately at the beginning of the succeeding statement. Or anywhere in the whitespace in-between. And that's the definition of a statement separator, rather than a terminator or an initiator.

    Just like you end questions with a questionmark. Or would you start sentences after a question with a question mark like this

    ?Looks odd, doesn't it ?

    Yes it does, but that is because that is invalid in the language that you are using (English). And it is invalid in English because "?" is an actual sentence terminator. On the other hand, this:;WITH ... is perfectly valid in the language that I am using (SQL). And again, this is because the semicolon is really a statement separator.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Christian Buettner (12/29/2008)


    Hi RBarryYoung,

    Why do you think it is not a statement terminator?

    I think that it is not a statement terminator because it does not meet the definition of a statement terminator. And I am basing that on your definition of a statement terminator (above).

    ;

    Transact-SQL statement terminator.Although the semicolon is not required for most statements in this version of SQL Server, it will be required in a future version.

    http://msdn.microsoft.com/en-us/library/ms177563.aspx

    SQL statements also include the semicolon (";") statement terminator. Though not required on every platform, it is defined as a standard part of the SQL grammar

    http://en.wikipedia.org/wiki/SQL

    Yes, Microsoft, Wikipedia and lots of other places call it a terminator. The problem is that it does not meet the definition of a terminator that most people would agree to. And this is exactly why I said that the semicolon is called a statement terminator but it is actually a statement separator.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Chris Harshman (12/29/2008)


    I think it's probably good practice to follow trends that are closer to the SQL standard than the local flavors that each vendor supports

    Heh... even though close to a million people are doing it wrong, it's still wrong. ๐Ÿ˜›

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • As far as I know the only case that I needed to use semicolon to terminate the statement is when I used GO as the procedure name

    create procedure go

    as

    select 45 as number

    Now this wont work

    GO

    but this

    GO;

    Here is Fun with GO

    http://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/05/fun-with-go.aspx


    Madhivanan

    Failing to plan is Planning to fail

  • If you change the connections default batch separator token from it's default 'GO' to something else, then (without ending semicolon)...

    GO

    .. will indeed work.

    /Kenneth

  • Cute trick, Madhivanan. Of course "[GO]" and "EXEC GO" would also work, but I like this.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • RBarryYoung (12/30/2008)


    Cute trick, Madhivanan. Of course "[GO]" and "EXEC GO" would also work, but I like this.

    Thanks for the feedback ๐Ÿ™‚


    Madhivanan

    Failing to plan is Planning to fail

  • RBarryYoung (12/29/2008)


    Yes, Microsoft, Wikipedia and lots of other places call it a terminator. The problem is that it does not meet the definition of a terminator that most people would agree to. And this is exactly why I said that the semicolon is called a statement terminator but it is actually a statement separator.

    Is your concern that it is not correctly implemented as a statement terminator in SQL Server?

    The MSDN link gives the info that It will be required for all statements in the future.

    So I agree that we are somehow in grey area right now with the current implementation, but according to the documentation in BOL (the link), the semicolon should really be a statement terminator, not just a separator.

    The difference according to my tiny theoretical knowledge is that

    a) you separate two or more statements with separators. (A;B;C)

    b) terminators end all statements, including the last statement or single statements. (A;B;C;)

    Let me know if this does not match your definition.

    Just as a sidenote - BOL 2005 mentions the semicolon as an "optional" statement terminator.

    Best Regards,

    Chris Bรผttner

  • BWA-HAA! See why I hate the damned things? You guys are still going on about punctuation marks... :P:hehe:

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Christian Buettner (12/30/2008)


    The difference according to my tiny theoretical knowledge is that

    a) you separate two or more statements with separators. (A;B;C;)

    b) terminators end all statements, including the last statement or single statements. (A;B;C;)

    Let me know if this does not match your definition.

    Ah, but now you've changed your definitions to suit your argument, and that's not really cricket, is it?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Jeff Moden (12/30/2008)


    BWA-HAA! See why I hate the damned things? You guys are still going on about punctuation marks... :P:hehe:

    Well, you started all this

    !:P

    No, point taken, this discussion leads to no important benefit.

    The time of the statement terminator will come (or might it might disappear, how knows). Until then I'll just agree that we disagree ๐Ÿ™‚

    Best Regards,

    Chris Bรผttner

  • RBarryYoung (12/30/2008)


    Christian Buettner (12/30/2008)


    The difference according to my tiny theoretical knowledge is that

    a) you separate two or more statements with separators. (A;B;C;)

    b) terminators end all statements, including the last statement or single statements. (A;B;C;)

    Let me know if this does not match your definition.

    Ah, but now you've changed your definitions to suit your argument, and that's not really cricket, is it?

    Hm, I must be missing something important here. Where did I define the statement terminator?

    Please quote.

    Thanks!

    Best Regards,

    Chris Bรผttner

  • Heh... wha? Moi? Oh... you mean I started it all with my "statement prefix"? ๐Ÿ˜›

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • :Wow: Can't we just all get along??? Personally I think there are things worse than semicolons in SQL, but I'm not going to get into them here. ๐Ÿ˜›

  • Chris Harshman (12/31/2008)


    :Wow: Can't we just all get along??? Personally I think there are things worse than semicolons in SQL, but I'm not going to get into them here. ๐Ÿ˜›

    Sure we can[font="Arial Black"]; [/font]If you want... ๐Ÿ˜›

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 15 posts - 31 through 45 (of 49 total)

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