Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The Importance of Reading Comments


The Importance of Reading Comments

Author
Message
Manie Verster
Manie Verster
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1308 Visits: 985
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
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8780 Visits: 16555
See my article here on SSC for more detailed info.

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

"Ya can't make an omelette without breaking just a few eggs" ;-)
Brandie Tarvin
Brandie Tarvin
SSCertifiable
SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)

Group: General Forum Members
Points: 7767 Visits: 8731
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/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
Vlad-207446
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 321
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
Perry Whittle
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8780 Visits: 16555
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" ;-)
scott mcnitt
scott mcnitt
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 429
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
Manie Verster
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1308 Visits: 985
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
Miles Neale
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2666 Visits: 1694
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
Brian J. Parker
Valued Member
Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)

Group: General Forum Members
Points: 64 Visits: 294
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
georgesquared
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search