Ending a line with a Backslash

  • Comments posted to this topic are about the item Ending a line with a Backslash

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I copied,  pasted and ran the code as-is and got the wrong answer.

     


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • Same with me, copied, ran the code and wrong answer.

    The line in the published code ends with a space, not with a backslash.

  • This look like SSC's text parser then adding a space. Nothing i can do about that. Unfortuantely I had a pig getting the thing to even look correct due to SSC's text parser treating the backslashes as a line continuation character... For example I type this:

    This is a linethis is another line

    Image of what I typed:

    And that'll be all on one in the published response.

    The QOTD in the editor dosen't even have any backslashes anymore:

    But why are you copying the code the get the answer in the first place..? 🙂

    • This reply was modified 1 year, 10 months ago by  Thom A.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • But why are you copying the code the get the answer in the first place..?

    Trust but verify 🙂  Besides, a true smart-alec would have known that a '\' would be a line continuation but '\ ' wouldn't be and they'd have seen the space and got it wrong.

    Don't get me wrong Thom, I had no doubt this wasn't your fault.

     

     

     


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • the code has a space after the backslash, works without problem

  • juanandres.gonzalez wrote:

    the code has a space after the backslash, works without problem

    Already discussed above. I'll try and fix the mess that SSC has made of this question in the editor.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I've resubmitted the question; hopefully the space isn't at the end any more, but it's very difficult to tell in SSC's editor I'm afraid, as it rips out of the backslashes after i submit the question. Will need to wait for it to be approved though.

    Looks like regardless of what I do now, SSC breaks on the the continuation character. Apologies but I can't fix this. I'll send an email to the webmaster.

    • This reply was modified 1 year, 10 months ago by  Thom A.
    • This reply was modified 1 year, 10 months ago by  Thom A.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • But why are you copying the code the get the answer in the first place..?

    Because I got a "Wrong Answer" when everything I saw before me should execute without problem.

  • Just got a bounce back from the "webmaster", as the email address is mispelt on the Contributions page (it has sqlservercental.com not sqlservercentral.com). Forwarded it to the correct address.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I got it wrong through ignorance rather than being a smart-alec. It might be obvious to some but it didn’t occur to me that a backlash at the end of the line would act as a line continuation, so despite the issues others have already mentioned, for me it was a good question as I learned something new.

  • A nice gotcha warning.  I was looking for permission related issues on the ImageFiles table, and not reading the title of the question.

  • I got it wrong, but it was because I expected the stored procedure to fail to get created.  I am a bit surprised that the stored procedure would get created with the second value of the insert missing and missing the closing bracket... but I suppose since it is just a string value being stored in that variable, the error wouldn't get thrown until you went to execute the dynamic SQL.  So makes sense.  I just didn't think about it enough before hitting submit.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!

  • Inside dynamic sql I prefer to use the /**/ comment to avoid bug in concatenation.

    Well Done.

  • Really interesting topic, thanks

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

Viewing 15 posts - 1 through 15 (of 15 total)

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