Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

The Importance of Reading Comments Expand / Collapse
Author
Message
Posted Sunday, June 9, 2013 9:27 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 25, 2014 5:21 AM
Points: 1,205, Visits: 923
Comments posted to this topic are about the item The Importance of Reading Comments

Manie 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)
Post #1461377
Posted Monday, June 10, 2013 12:09 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:20 PM
Points: 6,371, Visits: 13,709
See my article here on SSC for more detailed info.

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

"Ya can't make an omelette without breaking just a few eggs"
Post #1461398
Posted Monday, June 10, 2013 4:44 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:37 AM
Points: 5,575, Visits: 6,359
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 Administrator

Webpage: http://www.BrandieTarvin.net
LiveJournal Blog: http://brandietarvin.livejournal.com/
On LinkedIn!, Google+, and Twitter.

Freelance Writer: Shadowrun
Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
Post #1461473
Posted Monday, June 10, 2013 5:16 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Today @ 7:49 AM
Points: 36, Visits: 218
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





Post #1461481
Posted Monday, June 10, 2013 6:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:20 PM
Points: 6,371, Visits: 13,709
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

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"
Post #1461509
Posted Monday, June 10, 2013 7:15 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, September 18, 2014 5:39 AM
Points: 41, Visits: 378
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.
Post #1461533
Posted Monday, June 10, 2013 7:50 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 25, 2014 5:21 AM
Points: 1,205, Visits: 923
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.


Manie 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)
Post #1461561
Posted Monday, June 10, 2013 9:31 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 12:15 PM
Points: 2,345, Visits: 1,403
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!
Post #1461622
Posted Monday, June 10, 2013 10:21 AM


Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 11, 2014 1:06 PM
Points: 12, Visits: 66
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?
Post #1461656
Posted Monday, June 10, 2013 10:22 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 11, 2013 8:34 AM
Points: 4, Visits: 47
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.
Post #1461657
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse