Which is better

  • Christopher Stobbs (12/11/2008)


    Thanks for the alternative Jeff πŸ™‚

    but I must say sorry I don't know how the hanging ) stayed as it did.

    )

    )

    Lets see what happens he he he

    OK I got it.

    If you have a tabs instead of spaces before the ) then it stays as it should and no smiley πŸ™‚

    That is great - now, how the heck do you put a tab into this editor?

    Jeffrey Williams
    β€œWe are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Garadin (12/12/2008)


    Roger that. Just made the change. Mine was set to 8. It always kinda bugged me that it was so big, but never really bugged me enough to change it. Now set to 4, with save tabs as spaces. Still not sure about this whole terminating semi-colon deal though.

    I also have mine set to 8 - and have it replace tabs with spaces. As for the semi-colons, get used to it as it is going to be more and more required. For example, it is now required before the WITH statement when using a CTE.

    Jeffrey Williams
    β€œWe are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • . )

    )

    )

    )

    You copy and paste a tab from elsewhere =).

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. πŸ˜‰

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Jeffrey Williams (12/12/2008)


    Garadin (12/12/2008)


    Roger that. Just made the change. Mine was set to 8. It always kinda bugged me that it was so big, but never really bugged me enough to change it. Now set to 4, with save tabs as spaces. Still not sure about this whole terminating semi-colon deal though.

    I also have mine set to 8 - and have it replace tabs with spaces. As for the semi-colons, get used to it as it is going to be more and more required. For example, it is now required before the WITH statement when using a CTE.

    I think perhaps I don't understand where they belong. I tried putting one at the end of each line of code in SSMS 2K8 and it caused errors all over the place.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. πŸ˜‰

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • The semi-colon is a statement terminator, so you wouldn't put it at the end of every line. Only at the end of each statement - and only before the WITH statement if the previous statement is not terminated with a semi-colon (I put one there always, just in case).

    Jeffrey Williams
    β€œWe are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • All this Tab -> spaces debate made me curious... so I did a little test. I'm guessing this is due to it mimic'ing html or something when it converts the tab -> spaces, but that's just a thought being that it makes the wink smiley.

    Copied Space (NotePad)

    )

    Copied Tab (NotePad)

    )

    Copied Space (Query Analyzer)

    )

    Copied Tab (Query Analyzer)

    )

    Space Typed into Edit Box

    )

    Copied Tab (With Tab -> Spaces Turned on) (Query Analyzer)

    )

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. πŸ˜‰

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Lynn Pettis (12/12/2008)


    Jack Corbett (12/12/2008)


    I like tabs and I use 6 and I like to set it to 6 even if I change set it to use spaces. One of those personal things.

    I like four spaces, personal thing as well, as it helps keep the code from scrolling off the side of the screen. I don't mind scrolling up and down, but really hate it when I have to scroll up and down and left to right to see the code.

    Now that's really annoying ... but when you've got the scent it's hard to maintain the discipline innit?

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Christopher Stobbs (12/12/2008)


    Really why do you hate tabs πŸ™

    Just one reason... formatting. I spend a bit of time making sure that the code is properly indented for high readability. It seems like everyone has their own personal preference for what the tab stops should be set at not to mention the fact that a lot of programs (NotePad, Word, SMS, QA, forums, etc, etc) all have different default tab stops. So, when someone goes to use my code, it looks like crap because the tab stops are different. Spaces are spaces on every system and, with the exception of some forums that remove leading spaces, the formatting of the code is preserved when spaces are used instead of tabs.

    --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)

  • Ok... I tried a couple of things out and even the use of non-breaking spaces is no guarantee either in the normal window or a code window...this really stinks especially if you don't want to use tabs...

    Contains the indicated number of non-breaking spaces

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    Contains the indicated number of spaces followed by a non-breaking space

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    Contains the indicated number of tabs

    )--1

    )--2

    )--3

    )--4

    )--5

    )--6

    )--7

    )--8

    )--9

    )--10

    Contains the indicated number of non-breaking spaces

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    Contains the indicated number of spaces followed by a non-breaking space

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    Contains the indicated number of tabs

    )--1

    )--2

    )--3

    )--4

    )--5

    )--6

    )--7

    )--8

    )--9

    )--10

    This uses the & # 160 ; code... same as what the Simple-Talk prettifier uses... by itself, it doesn't work either...

     ) --1

      ) --2

       ) --3

        ) --4

         ) --5

          ) --6

           ) --7

            ) --8

             ) --9

              ) --10

    Neither does it work in a code window...

     ) --1

      ) --2

       ) --3

        ) --4

         ) --5

          ) --6

           ) --7

            ) --8

             ) --9

              ) --10

    ... but, if you use the Simple-Talk prettifier and don't make ANY changes, it comes out looking pretty decent...

    [font="Courier New"] ) --1

      ) --2

       ) --3

        ) --4

         ) --5

          ) --6

           ) --7

            ) --8

             ) --9

              ) --10

    [/font]

    I checked the code the prettifier uses... I just didn't see anything obvious in it that makes it work the way it does... I even tried to manually add the font and size codes and still got the smiley faces.

    But, then... I got it... two different ways...

    Here, I replaced all parenthesis with the & # 041 ; code (again, remove the spaces)

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    ... and here, I replaced the parenthesis with [ b ][ / b ]) (remove the spaces, again)

    ) --1

    ) --2

    ) --3

    ) --4

    ) --5

    ) --6

    ) --7

    ) --8

    ) --9

    ) --10

    It's still a pain in the haunches, and both still slam stuff to the left if there's only one leading space, but they both work nicely without having all the codes the prettifier puts in which can make things a bit difficult to edit if you need to.

    Now, if we can just get Steve to automatically change all right parenthesis to the 041 code in code windows only, and we'll be all set. Oh yeah, in case you miss them, here's a smiley face for ya... πŸ™‚

    --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 9 posts - 31 through 38 (of 38 total)

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