The Importance of Reading Comments

  • Manie Verster

    SSCertifiable

    Points: 7022

    Comments posted to this topic are about the item The Importance of Reading Comments

    :-PManie Verster
    Developer
    Johannesburg
    South Africa

    I can do all things through Christ who strengthens me. - Holy Bible
    I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)

  • Perry Whittle

    SSC Guru

    Points: 233859

    See my article[/url] here on SSC for more detailed info.

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Brandie Tarvin

    SSC Guru

    Points: 172757

    I agree. It's more than just reading code comments, though. Sometimes comments about the article itself can be just as important.

    I've seen several MSDN articles marked as incomplete or having bad syntax in the comments that users post to the articles. And sometimes commenters can point out other ways of accomplishing a task, or better performing methods.

    But the biggie is when commenters let the article author and the world at large know when a key piece of information is missing from the code. Hence, reading comments can be a good thing when looking for solutions. All comments.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Vlad-207446

    Right there with Babe

    Points: 773

    I don't get it.

    the script is great, but if you have to physicaly move the files your self anyway, than wouldn't just

    stop the db, detach files , move them and attach them back work as well?

    that is what MS recomends after all

    http://support.microsoft.com/kb/224071

    #1 get the curent file location

    use <database_name>

    go

    sp_helpfile

    go

    #2 detach db

    use master

    go

    sp_detach_db 'mydb'

    go

    #3.Copy the data files and the log files from the current location (D:\Mssql7\Data) to the new location (E:\Sqldata).

    #4. reatache files from new location

    use master

    go

    sp_attach_db 'mydb','E:\Sqldata\mydbdata.mdf','E:\Sqldata\mydblog.ldf'

    go Verify the change in file locations by using the sp_helpfile stored procedure:

    #5 check the db file liocation

    use mydb

    go

    sp_helpfile

    go

  • Perry Whittle

    SSC Guru

    Points: 233859

    Vlad-207446 (6/10/2013)


    I don't get it.

    Read my article it will expalin in more detail.

    Vlad-207446 (6/10/2013)


    but if you have to physicaly move the files your self anyway, than wouldn't just

    stop the db, detach files , move them and attach them back work as well?

    that is what MS recomends after all

    http://support.microsoft.com/kb/224071%5B/quote%5D

    You can't always just detach the database, it may be replicated for instance. This article details moving the files via the ALTER DATABASE command is the supported route from Microsoft.

    You have chosen to link a rather ancient article that covers SQL Server 7.0, 2000, 2005 which is no longer relevant. Under SQL Server 2000 you had to detach a user db to move it as the alter database command was only valid for tempdb files

    My article provides a lot more detail behind all this.

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • scott mcnitt

    SSC Eights!

    Points: 998

    It seems like a bad idea to find a script on the Internet and just run it -- whether you read the comments or not!

    Look up and understand each statement and what it will do.

  • Manie Verster

    SSCertifiable

    Points: 7022

    The point of this article is not whether it is the best way of doing it but to READ the whole article and/or comments BEFORE you start because you could just one day bring down the whole database/s.

    For this specific purpose I wanted to learn something new and for that reason I did the move database script.

    I hoped that with this article somebody could learn from my mistakes. That and only that is the reason for this article.

    :-PManie Verster
    Developer
    Johannesburg
    South Africa

    I can do all things through Christ who strengthens me. - Holy Bible
    I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)

  • Miles Neale

    SSChampion

    Points: 13147

    scott mcnitt (6/10/2013)


    It seems like a bad idea to find a script on the Internet and just run it -- whether you read the comments or not!

    Look up and understand each statement and what it will do.

    Scott not only does it seam like a bad idea it really is a bad idea. Remember the old statement "Look before you leap!" Even as a child we were warned to not just run it. Problem is many did not listen then and about the same percent don't listen today.

    M...

    Not all gray hairs are Dinosaurs!

  • Brian J. Parker

    SSC Eights!

    Points: 879

    Thank you for being willing to share an embarrassing story! I bet we have all made big mistakes, but we aren't all brave enough to admit it.

    It is a good lesson to read first, for the reason you point out, AND because reading an explanation of the script can often teach us something.

    As someone who writes a lot of scripts that might be used by others, I also take away another lesson about comments. At the point in the script where you should move the files, I think there should be a code comment reminding you to do so. That isn't to forgive lack of reading, but why not make our scripts as friendly as possible?

  • georgesquared

    SSC Journeyman

    Points: 80

    Yes, read comments in the code and read comments after the post and double check the information against multiple sources & blogs.

    and there's a flip side for posters: make your examples as complete and bullet-proof as possible. If I were posting this code, I would have done the following:

    - parameterize the source & destination paths

    - embedded an xp_cmdshell statement to copy the files over in the script

    - look for multiple database file devices.

    --- flag if they span multiple drives, perhaps for load balancing, etc.

    --- There is no guarantee that a DB will have only one data & one log device, or that the names will follow a standard.

  • vyengr

    Grasshopper

    Points: 19

    This is reminiscent of the "test" they gave perdiocally when I was still in school. The instructions said "Read the entire test before starting." The questions were quite time consuming to answer and it was a timed test. Of course if you did read the whole test before starting you would find an instruction at the very end saying "Answer only Questions 1 and 2 and ignore the rest."

  • Brandie Tarvin

    SSC Guru

    Points: 172757

    vyengr (6/10/2013)


    This is reminiscent of the "test" they gave perdiocally when I was still in school. The instructions said "Read the entire test before starting." The questions were quite time consuming to answer and it was a timed test. Of course if you did read the whole test before starting you would find an instruction at the very end saying "Answer only Questions 1 and 2 and ignore the rest."

    I remember that thing. The first two instructions indicated that you were to put your name and date on the test (different spots, depending on the test) and that was it.

    Annoying but funny.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Manie Verster

    SSCertifiable

    Points: 7022

    You have chosen to link a rather ancient article that covers SQL Server 7.0, 2000, 2005 which is no longer relevant. Under SQL Server 2000 you had to detach a user db to move it as the alter database command was only valid for tempdb files

    Perry, I don't know why you say this is an ancient article because after having had a look at it again I saw SQL Server 2012 at the top of the page??????:hehe::hehe:

    Thanks for the positive feed back and remembering I am not a DBA, I still have a lot to learn and am greatful for a forum like this to learn from.

    I would, however, like to know what is actually the best to do. Move or detach an attach taking in consideration that there is no replication on the database to be moved?

    :-PManie Verster
    Developer
    Johannesburg
    South Africa

    I can do all things through Christ who strengthens me. - Holy Bible
    I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)

  • Manie Verster

    SSCertifiable

    Points: 7022

    I remember that thing. The first two instructions indicated that you were to put your name and date on the test (different spots, depending on the test) and that was it.

    Many times I sat in that exam room and the only questions I knew was right was my name and the date!!!:hehe::hehe::hehe::hehe:

    You sit there and strike a complete blank even though you have studied so hard and late nights!!

    :-PManie Verster
    Developer
    Johannesburg
    South Africa

    I can do all things through Christ who strengthens me. - Holy Bible
    I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)

  • simonholzman 14059

    SSC-Addicted

    Points: 459

    I have a habit of putting a word at the end of the section BEFORE the comment that is not commented out but is invalid (I often use my nickname SIGGY). This stops the script at that point if I hit F5 without selecting the previous section.

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

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