SQLvariations: SQL Server, a little PowerShell, maybe some Hyper-V Rotating Header Image

October, 2009:

PowerShell 2.0 for XP and Up

If you haven’t heard the news, PowerShell 2.0 for Windows XP, Windows Server 2003, Vista, and Windows Server 2008 R1 has now been released. This is huge.  Especially for SQL folks. It’s huge because  I can once again share my PowerShell scripts with colleagues who use different operating systems.   More on why it’s huge here:  Halr9000.com Where Can I get it?!?!  Right here: http://support.microsoft.com/kb/968929 I’m a SQL Server DBA, why do I care about PowerShell?..   The other day one of the Sys. Admins. came to me and asked me how large our data files are so that he could calculate the drive spaced need for migrating to our new SAN.  I of course dropped what I was doing to gather this info for him.  Now I went through SQL to get the info but because we still have a few SQL Server 2000 machines, a few of them were undercounted!  When the Sys. Admin.  compared our lists he found one discrepancy amidst the over 600 data and log files I listed.  One database only had 4 files but they were 4 massive files (100+GB).  If Only I could cross-reference this information with what the O/S thought was there!  I’m working on a recusive script to cycle through mount points and give me a system wide total.  What I’ve put together so far is a script to calculate the total the size of all the .mdf’s in any directory you point to:  cd C:\Program` Files\Microsoft` SQL` Server\MSSQL10.KATMAI\MSSQL\DATA #Change me to YOUR directory $c=0 $l=0 foreach ($f in dir *.mdf) {$c += 1; $l += $f.length} “File Count: $c” “Total size of .mdf files in Bytes: $l” Need to count your .ndf and .ldf files too? Just append a “, *.ndf” or “*.ldf”  immediately following the *.mdf Now I don’t know if a PowerShell expert would suggest this approach, I just know that I tried it on my machine and it worked! (However, if  you’re still  storing your .ndf’s and .ldf’s on the same drive let alone same directory as your .mdf files there is a whole other conversation we should have.) Oh you need to output that to a text file so that you can email it to someone?  Just change out the last two lines (the ones in brown) for this:    “File Count: $c Total size of .mdf files in Bytes: $l” > c:\Temp\MydbFileSized.txt Now I know that formatting that bytes number with some commas or at least translating it into MB would be nice but that will have to wait until another post.  Until then, have fun with what you got and tell me what you need. @SQLvariant

Highlights from SQL Saturday #21 in Orlando

Last weekend I attended SQL Saturday #21 in Orlando.  For those of you sleeping your way through work, SQL Saturday is a series free training events that focus on local professionals sharing knowledge. (And yes, some of us do get so excited about data that we give up a Saturday and drive 500 miles to learn even more.)  Saturday #21 featured topics ranging from managing SQL Server on a SAN to Policy Managing and Compliance strategies.  If you missed this event the next best thing is to check out the blog posts from some of the presenters: Jonathan Kehayias, Andy Warren, Jorge Segarra, and Max Trinidad. And while you are at it check out the SQL Saturday schedule and plan to attend the next one near you.  It’s great free community-based training. I’ll try to put together a blog post in the next week about how I was able to apply what I learned at SQL Saturday #21.  Here’s the schedule that I picked out for myself and what those blog posts might end up being about: Kevin Boles SANs and SQL Server Jorge Segarra Policy Based Management 101 Jonathan Kehayias Auditing User Activity 101 Max Trinidad PowerShell and SQL Server (More SMO) Chad Miller SQL Server PowerShell Extensions Buck Woody SQL Server Resource Governor I hope to see you at the next one!!  @SQLvariant (Now if they’ll just post the link to SQL Saturday in Tampa January 2010!)

My first BLOG-post EVER

What a BLOG? Seriously?? Have you met me. I like to run off at the mouth not at the fingertips. What do I know about blogging? Don’t they come from Antwerp? I’m finally giving in as starting a BLOG.  Who knows how long this will last or how many people will read it, but I’m starting.  How am I going to do this you say!  Well I read some blog-posts by this guy named Brent Ozar “Blogging for a Living”…  ok “read” might be too strong of a word but I skimmed a few of the words in his 5-part series on how to start a BLOG.  (Great stuff btw Brent, really helped!)  So anyways, at somepoint I’m going to go back and actually read those articles, in the meantime though I’ve go an idea for my “Second BLOG-post EVER” so actually learning how to blog is just going to have to wait.  http://www.brentozar.com/twitter/how-to-start-a-blog/ The first couple of weeks, maybe even months of this are going to be a bit rough because, well, I don’t know how to read let alone type.  (For the record, I don’t read, I memorize, takes a really long time.)  If you have ever received an email from me you know just how laconic I can be.  I’ll try to break that habit but not right now.  First I want to get into the habit of having something to say at least once a week, every week.  I’m not going to promise to be useful or entertaining or anything, I’m just going to promise to say something, in text format (of at least 17 words) every week.  And who knows, one day, somewhere out there, this BLOG might just finally your life server/database’s life. So to start out: This BLOG is about my undying love for trials and tribulations with SQL Server and all of it’s friends (you know: SSIS, SSRS, SSAS, SQL Agent, Replication, Clustering, Virtualization, stuff like that).  I’m going to blog about a few random things that probably have no connection whatsoever.  I might start something, post it just to get it out there, and then come back and edit once I’ve thought about it some more for a bit. Why might you care? Well I’ve been doing this whole database thing for over 10 years and I’m telling you, one of these days, this whole “software” thing is really going to take off.  I hold MCITP: credentials in Business Intelligence Developer, Database Administrator, Database Developer; so i know how to RTFM (usually).  I run into the occasional error that no one has run into yet and tons of errors that plenty of people have run into; and I plan to catalog them here.  This will be my cheat-sheet for fixing problems that I’ve already run into so feel free to use my copy and tell me stuff that you think I should add.  If you have any questions about any of the SQL Server certifications exams (Admin, Dev, or BI.  2005 or 2008) and how you should go about preparing for them feel free to ask. So here goes. T Minus X:XX until my Second BLOG-post EVER! Oh and…  please, comment. ( That’s right, I just said that I want to hear someone’s opinion besides my own )