Subtle Line Feed / Carriage Return issue

  • Looking at too much script makes my head swim, now I can't make heads or tails of it. But I, too, got 1,2,3,4.

  • dbuendiab (12/23/2010)


    Anyway, I admit it was a sure-you-lose-question.

    There are other ways to get points.

    The only loss here is your time for what looks like a cut and paste error.

    :w00t:

  • This was removed by the editor as SPAM

  • Carlo Romagnano (12/23/2010)


    Some tools (powerbuilder,qlick) replace CR and LF with space, so one line comment

    in the script could alter the command.

    Running the script in sql2000 I get 1,3,4 but in sql2005 + sp I get 1,2,3,4.

    Running script in PowerBuilder I get just a comment

    -- comment 1 print 1 -- comment 2 print 2, etc.

    What about Quick Base or FileMaker?

    I would guess they get the same result.

  • Might as well add me to the list of having the right answer and getting it marked wrong.

    A QotD on a bug that has been fixed for years is a poor QotD



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • stewartc-708166 (12/23/2010)


    par for the course....

    CR was a placemarker character, left over from the old typeset days, which told the typesetter to go to the begining of a line (or the first available space thereafter). It was thus used in conjunction with the NL character which, without it, would cause the cursor to go to the next line, but continue from the same position.

    Just FYI, different Operating systems do it differently anyway.

    I'm pretty sure Unix/Linux doesn't put both CR and LF (Carriage Return and Line Feed) characters at the end of a line in a text file. As I've learned when I open said documents in notepad. Other text editors for Windows (Programmers File Editor as an example) treat the one character (instead of two) text files with no trouble and open them up with formatting intact.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • I got 1,2,3,4 as a result too.

  • SQL 2005 provides the following output:

    What you see...

    -----------------------

    print 1

    -- Comment one

    print 2

    -- Comment two

    print 3

    -- Comment three

    print 4

    is not what you get!

    -----------------------

    1

    2

    3

    4

    Need to correct your answer.

    Raymond Laubert
    Exceptional DBA of 2009 Finalist
    MCT, MCDBA, MCITP:SQL 2005 Admin,
    MCSE, OCP:10g

  • Good question but wrongly framed.

    Oh......I lost a point too. Damn, Bad beginning for a Christmas eve.

    SQL DBA.

  • Ran this under SQL Server 2005 SP3 (9.0.4053) and got following results:

    What you see...

    -----------------------

    print 1

    -- Comment one print 2

    -- Comment two

    print 3

    -- Comment three

    print 4

    is not what you get!

    -----------------------

    1

    2

    3

    4

    Interestingly, in Management Studio the '-- Comment one' and 'print 2' display on separate lines and apparently are parsed that way, but when copied/pasted into this window they are combined on the same line. This could have been a better question, with answers that don't depend on an unpatched old version of SQL Server.

  • Bug must be fixed in 2008:

    What you see...

    -----------------------

    print 1

    -- Comment one

    print 2

    -- Comment two

    print 3

    -- Comment three

    print 4

    is not what you get!

    -----------------------

    1

    2

    3

    4

  • Only if you've failed in the server patch department- this was fixed SQL Server 2005 SP1

  • Thanks for the question. It would have been nice to have something a little more current.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I also got 1,2,3,4 so not sure what the question was trying to show - no bug here!

  • the question would have been alright in 2005 when that was an issue

    so the only people to get the question right were people have fully patched sql 2005

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

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