none
Copying Line Numbers along with code?

    Question

  • I'm creating a catalog of common queries I use, and want to paste the code into a Word Document. Is there a way of copying the line numbers along with the code?

    I could create an elaborate numbering scheme in Word, but don't really want to :)


    • Edited by cvermette Thursday, February 14, 2013 6:19 PM
    Thursday, February 14, 2013 6:17 PM

Answers

  • It is annoying when you copy query code from webpage with the line number. Since you want the line number with your code, you can try to post your code in a Wordpress blog page with code block in this format:

    [sourcecode language="sql"]

    --Your code goes here.

    [/sourcecode]

    When you view your page, you will see the line numbers along with your code. You can copy the code directly from the page block, you will have both code and line number if you paste it to Word.

    If you want to remove the line number, you can use view source tab from the block header part to copy code. I don't know whether  this offer you an option.

    • Marked as answer by cvermette Thursday, February 14, 2013 7:54 PM
    Thursday, February 14, 2013 7:00 PM
  • Adding Line Numbers in word isn't too bad, check this link:

    http://office.microsoft.com/en-gb/word-help/add-line-numbers-HP005231243.aspx

    Perhaps a better alternative would be to list your queries & comments within a .SQL file instead of a word document?

    Edit: Just noticed the link is for 2003, either way you can add line numbers from the "Page Layout" section.


    Zach Stagers - scratchbox.co.uk
    MCITP: Database Developer 2008
    Remember to Mark as Answer and Vote as Helpful




    • Edited by Zach Stagers Thursday, February 14, 2013 7:00 PM Added comment about link
    • Marked as answer by cvermette Thursday, February 14, 2013 7:57 PM
    Thursday, February 14, 2013 6:56 PM

All replies

  • Unfortunately there is not.  You can include column headers, but there is no option to include the line numbers

    Hope this helps


    David Dye My Blog

    Thursday, February 14, 2013 6:48 PM
  • Adding Line Numbers in word isn't too bad, check this link:

    http://office.microsoft.com/en-gb/word-help/add-line-numbers-HP005231243.aspx

    Perhaps a better alternative would be to list your queries & comments within a .SQL file instead of a word document?

    Edit: Just noticed the link is for 2003, either way you can add line numbers from the "Page Layout" section.


    Zach Stagers - scratchbox.co.uk
    MCITP: Database Developer 2008
    Remember to Mark as Answer and Vote as Helpful




    • Edited by Zach Stagers Thursday, February 14, 2013 7:00 PM Added comment about link
    • Marked as answer by cvermette Thursday, February 14, 2013 7:57 PM
    Thursday, February 14, 2013 6:56 PM
  • It is annoying when you copy query code from webpage with the line number. Since you want the line number with your code, you can try to post your code in a Wordpress blog page with code block in this format:

    [sourcecode language="sql"]

    --Your code goes here.

    [/sourcecode]

    When you view your page, you will see the line numbers along with your code. You can copy the code directly from the page block, you will have both code and line number if you paste it to Word.

    If you want to remove the line number, you can use view source tab from the block header part to copy code. I don't know whether  this offer you an option.

    • Marked as answer by cvermette Thursday, February 14, 2013 7:54 PM
    Thursday, February 14, 2013 7:00 PM
  • Thank you Jingyang. You are right that the line numerbs are an annoyance if you want to paste the code in SQL Server (Which is what I want the reader to do). So I think I'll abandon the idea of line numbers. Thanks again.

    Thursday, February 14, 2013 7:57 PM
  • Thnaks David, that was my suspicion. thanks to some other folks who answered I think I came up with a better solution. You did save me from a dead end, and that's a big help!
    Thursday, February 14, 2013 8:11 PM
  • Zach I thought of that. The problem is that when you restar the line numbers at 1 Word adds a start and end page break to teh selection or section. A solution in some circumstances (and one I'll keep my my toolbox, but not viable for what I'm doing (but see below - you did give me a solution!)

    • Edited by cvermette Thursday, February 14, 2013 8:16 PM
    Thursday, February 14, 2013 8:15 PM
  • Zach it looks like I accidentally deleted another response you gave, which I decided was my solution: jsut use a SQL project file

     
    My orignal thought was that I wanted a catalog format with a TOC or index describing what queries were available. I can do that as follows:  I Create a project file with all of the queries, and put addiitonal comment in the code  (Something we shoud all do anyway...). Then, put all the queries in a project file, giving then clear, descriptive names. Lastly, I create a query called "Read me First" which is just one long comment with an index of the catalog.

    Thursday, February 14, 2013 8:20 PM
  • and I was wrong about line numbers! You can supress them for paragraphs/selections and they resequence:

    http://office.microsoft.com/en-gb/word-help/skip-line-numbers-for-specific-paragraphs-HP005189529.aspx?CTT=3


    • Edited by cvermette Thursday, February 14, 2013 8:25 PM
    Thursday, February 14, 2013 8:25 PM