DBPedias

Your Database Knowledge Community

Jen McCown

  1. We’re speaking at PASS Summit 2013!

    PASS liked our “Mouth Wide Shut” interviewing session from last year so much that they’ve decided to have us back for part two: Mouth Wide Shut: Interviews from the Other Side of the Table.

    This is our brand-spanking-new session for the interviewERs…those who question, vet, and rant about it afterward. Check out all the details on the PASS Session Details page. And while you’re there, feel free to take a look around at the other community sessions.

    So, to review:

    There, I think we’ve covered it all.

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  2. My 2013 SQL Saturday Schedule!

    I’ve finally gotten my gear together for (what I consider) the “speaking season”. Here are the SQL Saturdays that I’m speaking at, or that I’ve submitted to, or are considering submitting to! I’ll update this list as plans solidify:

    • 5/18/2013 – Atlanta - Scheduled to speak.
    • 8/3/2013 – Baton Rouge - Submitted. Call for speakers closes 6/1/2013
    • 8/17/2013 – NYC - Considering. Call for speakers closes 6/18/2013
    • 8/24/2013 – OKC - Submitted. Call for speakers closes 6/21/2013
    • 9/14/2013 – KSC - Submitted. Call for speakers closes 7/16/2013
    • 9/28/2013 – Denver - Considering. Call for speakers closes 7/30/2013
    • 10/15/2013 – PASS SummitSubmitted. Call for speakers closed.
    • 12/7/2013 – D.C. - Considering. Call for speakers closes 10/8/2013

    Let me know where you’re going to be! Maybe we’ll cross paths, shake hands, share info, sing a song…

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  3. Use Powershell to find and punish – er, delete – rogue files

    I like to know what’s on the drives that are supposed to be dedicated to data and log files. So I run a quick check of sys.master_files:

    SELECT LEFT(physical_name, 1) as Drive,
    SUM(size)*8/1024 as SizeMb
    FROM sys.master_files
    GROUP BY LEFT(physical_name, 1)
    ORDER BY Drive;

    And then I compare the numbers I got back against what Windows says. Hmm, odd. SQL says it’s using up 296,869 Mb (that’s ~289 Gb) of space on U:\, but when I go to Start > Computer it says it’s using up 390Gb of space on U:\.

    Rogue files! Rogue files on my data drive! I now have to HUNT DOWN AND PUNISH those 101 Gb of files freeloading on my data drive. And oh, how they’ll pay….

    First, Gather Data and Compare

    Step 1: Get the physical_name of all files on that drive from sys.master_files. That’s easy: SELECT physical_name FROM sys.master_files WHERE physical_name like ‘U%’;

    Step 2: Open powershell, navigat to U:\, and run get-childitem -name -recurse -filter *.*

    Step 3: Compare the lists. You can, of course, import to SQL and compare that way, or just paste each list into Excel for a look-see.

    Sure enough, there were about 100Gb of duplicate data files – MDFs, NDFs, and LDFs, if you can believe it! – on that server that hadn’t been touched in years. Time for vengance…

    Delete Files, if you Dare

    There are a number of ways we could go about removing these files, of course. In my case, it so happens that all my current, supposed-to-be-there files have recent modification dates, and everything else is pre-2012. That makes it very easy!

    Let’s start with a test script, that will just list the things we want to delete:

    get-childitem “U:\SQL03\” | where {$_.lastwritetime -lt (get-date).adddays(-365) } |% {write-output $_.fullname}

    Explanation:

    • get-childitem “U:\SQL03\” |    Get all objects in the specified directory, and pipe them to the next operation.
    • where {$_.lastwritetime -lt (get-date).adddays(-365) } |  Test each item’s “last write time” date against today -365 days; if they’re earlier than that date, pipe them to the next operation.
    • % {write-output $_.fullname}   Take each item and output its name.

    Awesome. All we have to do to change this into a dangerous, file-destroying script*is to replace write-output with remove-item.

    Wait, I could use this to routinely clean up old backups too, right?Schedule powershell as an Agent job

    Funny you should ask! Yes.

    Let’s say you want to delete backup files in a dedicated folder that are older than N days, and repeat regularly. Just take this and schedule it in a SQL Agent job! (You might want to change the -365 to -30, or whatever your given retention period is, in days.)

    Yeah, but my SQL backups go to a UNC share :(

    Except that your backups aren’t on a local drive; they’re on a UNC share, and you’re getting a weird error. No problemo!

    Your new, file-destroying script* that will indeed delete all files older than 30 days now looks like this:

    cd “\\Server01\SQLShare”; get-childitem “\\Server01\SQLShare \SQL03\FULL” | where {$_.lastwritetime -lt (get-date).adddays(-30) } |% {remove-item $_.fullname}

    Let’s make this slightly safer, and only delete the *.bak files older than 30 days:

    cd “\\Server01\SQLShare”; get-childitem “\\Server01\SQLShare \SQL03\FULL” -filter *.bak | where {$_.lastwritetime -lt (get-date).adddays(-30) } |% {remove-item $_.fullname}

     There we go, wielding Powershell like Foe-hammer in a goblin cave**. Feels good, don’t it?

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    *Note that the sys.master_files “size” column isn’t in Mb, but in pages.  To translate pages to Mb, SELECT name, (size*8)/1024 as SizeInMb from sys.master_files.
    *Which you will test thorougly before you use in a production environment, So Help You Codd.
    ** Too nerdy?

    Inspirational code source: Powershell delete files in subfolder older than 30 days with out deleting subfolders

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  4. Quick Tip: Navigating to a UNC within SQLPS

    I’ve been getting a funky error with a new Powershell script, running as a SQL Agent job step. Let’s pretend for the moment that the script is simply “cd \\backup\SQL; dir *.bak

    The error information returned by PowerShell is: ‘Cannot find path ‘\\backup\SQL’ because it does not exist.

    The script I have runs fine manually in Powershell, but not in SQLPS. The job itself runs under the SQL Agent service account, which is an AD account, which has full permissions to the share. That should really cover all the bases, shouldn’t it?

    As it turns out, no. A web search turned up this exact issue in Microsoft Connect. At least the workaround is simple! You have to get out of the SQL Server “context” in SQLPS before you try to hit a UNC path. So I just added this to the start of my script:

    cd c:\;

    Making the full script like this:

    cd c:\; cd \\backup\SQL; dir *.bak

    And that’s it! I do love a simple solution…

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  5. Quick Tip: Where’s my SQL Server Job History?

    Here’s a quick mystery. You have a SQL Server with several jobs that appear to be running properly and on schedule, but many of them show no history. You look around, and there doesn’t seem to be a nightly job history purge (you’re looking for something with “sp_purge_jobhistory“).  So where is the record of these successful job runs?

    Hm. Well, let’s take a quick look at the sysjobhistory table:

    SELECT * FROM msdb..sysjobhistory;

    Huh…that returned over 990 rows! So SOME jobs are showing history. But my Full backup ran successfully last weekend, and the record’s not in here!

    The answer is simple, if a tiny bit obscured: Your job history log is set to only store a certain amount of information – in this particular case, 1,000 rows. And we’re running a LOT of jobs frequently, every day. That pushes out the old information.

    Just resize your job history log (right click SQL Agent, Properties, History) to keep the amount of history you want.

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  6. In which we compare CISPA to Rick Astley

    Wherever you click, either CISPA or Rick Astley is there…

    I’m studying up on CISPA for a segment on our webshow.  Even though you’ve heard CISPA and SOPA and PIPA and online privacy so many times it’s like an audible, political Rickroll….even so, you should give a great big rat’s ass.

    Here is the cliff’s notes version of why:

    1. The constitution says your stuff can’t be searched or taken by the government, without a proper warrant.
    2. That’s good, because even if you’re an angel, your life shouldn’t be subject to scrutiny at a whim. Privacy matters.
    3. As it stands, CISPA would not only allow, but ENCOURAGE, private companies to give all your data to the government.
    4. The international intelligence agency side of the government, included.
    5. And with very few (if any) restrictions, or even definitions.
    6. That’s bad.
    7. Go* to https://cyberspying.eff.org/ and take a couple of clicks to email your representatives.

    *Feel free to read up more, first.

    Want to read more about it?

    Here are some outstanding sources:

    Happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  7. Remembering Alan Weber, @Aauugold

    We lost someone this week. We lost a fellow SQL-ite, a Twitterer, a DBAs@Midnight chatroom live chatter. We lost someone smart and funny, and I’m not remotely qualified to write his tribute…I only met him once or twice.

    Last week, we saw Alan enter the chatroom mid-show, and we said our usual “aaaaauuuuGOLD!”  He said he’d been out for surgery, and we all chatted about that a bit, and then went on with the show. Today we heard online, from folk in his user group, that he’d died. It’s just like that, sometimes.

    We didn’t know Alan well, like I said. We were always happy to see him Friday nights. I know that somewhere, people are missing him. I’m sorry he’s gone. I’m sorry for their loss. Ours, too.

    We’ll hold a small tribute in the preshow tonight at webshow.MidnightDBA.com. If you want, come by at 10:30 Central time and join us.

    -Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  8. The New MidnightDBA.com is live!

    GUYS! GUYS! GUYS!!!  We’ve finally completed the MidnightDBA.com facelift that many of you have been begging (nagging, pining, etc.) for, for the last few years quite some time now.  The site is in early version, “just get it working right” mode. But you will notice:

    • You can view MidnightDBA.com successfully in more than one version of more than one browser.
    • MidnightDBA.com now works on mobile devices.
    • Menus don’t play hide-and-go-click any more.

    As Sean put it: we’re not sitting on our laurels, either. We’ve got some really cool stuff planned for the coming weeks.

    Definitely check it out, let us know if you see anything major (or minor) wrong. And hey, why not tell us what you like, as long as you’re there?

     

    Happy, happy days,
    Jen McCown
    http://www.MidnightDBA.com/Jen

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  9. T-SQL Tuesday #40 Roundup: Files and Filegroups

    Good day all, and happy T-SQL Tuesday #40! Yes, this event has officially hit middle age now. I fully expect it’ll go get itself a fast car in the upcoming months.

    We had a great turnout for this month. “Files and Filegroups” is an open enough topic that I got exactly what I wanted: A nice variety of blog posts, all over the spectrum. We got introductions and issues, solutions, Powershell, mysteries, and more. Dig it! There’s not a bad blog in the lot!

    Rob Farley: Filegroups and Non-Clustered Indexes

    Rob wrote an absolutely fantastic primer for filegroups, with useful code, that I’ll be pointing people to regularly from here on out.

    Jason Brimhall: T-SQL Tuesday #040: File and Filegroup Wisdom

    Jason had a “filegroup not online” issue just in time for T-SQL Tuesday! He walks us through his solution here.

    Merrill Aldrich: T-SQL Tuesday #040: Files, Filegroups and Visualizing Interleaved Objects

    Merrill gives us an early lesson in storage internals, demonstrating the file proportional fill algorithm. He’s made us a demo, so you can follow along at home! (Bonus points for his Lord of The Rings reference.)

    Patrick Keisler: T-SQL Tuesday #40 – Proportional Fill within a Filegroup

    Patrick gives us another take on the proportional fill algorithm, with an emphasis on space used.  I like having the two perspectives on this topic!

    Robert Davis: Day 30 of 31 Days of Disaster Recovery (T-SQL Tuesday #40): Using Partial Availability and Initialize from Backup to Replicate a Partial Database

    Robert used T-SQL Tuesday as day 30 of his “31 days of Disaster Recovery”…awesomesauce!

    He discusses the pros and cons of a scenario: we want to replicate only part of a very large database (without initializing from snapshot, or copying and restoring the whole database backup).

    Bob Pusateri -: Moving A Database to New Storage With No Downtime

    Bob tells us his story about migrating a large number of files to new storage, with no downtime. He considers his options in detail, and goes with a hybrid solution. Bob demonstrates this with scripts and diagrams, with “circles and arrows and a paragraph on the back of each one…”  This is a great blog in a group of great blogs here, dig into it!

    Chris Yates: T-SQL Tuesday #040: File and Filegroup Wisdom

    Chris talks about one simple but lovely premise: “You can achieve performance gains by created non clustered indexes on a different filegroup if the filegroups are using different physical drives.”

    Chris Fradenburg: T-SQL Tuesday #040: File and Filegroup Wisdom [Powershell alert!!]

    Chris has an interesting take on this month’s topic:  How Powershell treats filegroups and files!

    Thomas Stringer: T-SQL Tuesday #40: Get Filegroup Count and Default Configuration with PowerShell

    Another Powershell blog! I wasn’t expecting that. Thomas explores a method to find out how many filegroups a database has, and whether the PRIMARY filegroup is default.

    Hemanth Damecharla: T-SQL Tuesday #040: File and Filegroup Wisdom (Quick Introduction to FILESTREAM)

    Hemanth takes this opportunity to give us an introduction to FILESTREAMs (it counts, because it needs its own file group).

    (By the way, if you’d like an extension on this topic, take a look at my blog “FileTable: SQL Server 2012′s little gasp-maker“.)

    Steve Jones: T-SQL Tuesday #40– File and Filegroups

    Steve gives us another introductory Filegroups and Filestream piece that dovetails nicely with Hemanth’s. It’s got a nice walkthrough, and links to Steve’s talks on the subject.

    Sean McCown: T-SQL Tuesday: A file delete exercise

    Wrapping up this month’s T-SQL Tuesday is our very own fellow MidnightDBA, Sean….who gives us homework! Well, not exactly, but we hear about assignments he’s given over the years, with surprising conculsions. And of course, the repro.

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  10. Twitter Talk Theatre, Episode 1: “RAID is good enough!”

    But We've Never Had a Disaster Before!

    But We’ve Never Had a Disaster Before!

    This week, some of my Twitter followers were kind enough to chime in on a topic near and dear to my heart: the proper caretaking of SQL Server. Here is some of what we said.

    Me: Common scenario: A company has databases, but no “assigned” DBA. So, broken backups, no maintenance, no disaster recovery. Guys? I can help.

    @wnylibrarian But they’re backing up the VM that the databases are on. That’s enough, right? ;-)

    Me: If you don’t mind giant logs, no DR…

    Me: Pop quiz, my people: Tell me WHY RAID isn’t enough. (Hold off on answering, if you’ve written a book about this…)

    ‏@SQLBob because a disaster is way more than just a drive failing!

    Me: DING DING DING DING! Winner!! Other answers accepted…

    @williamweber DB corruption, I choose you!

    Me: Well done, have a cookie.

    @AirborneGeek My usual short/sweet answer is: Data redundancy is not data backup.

    @wnylibrarian Because its not a true DB backup. There are consistency issues.

    @adamhill Time to rebuild failed drives and soft failures during the rebuild that cause rebuilds of the rebuilds on very large HDDs?

    Me: Well done [@AirborneGeek]. You also get a cookie. Also @wnylibrarian & @adamhill

    ‏@crummel4 b/c sometimes a second disk fails before ops can swap the first. Like two failures w/in 5 minutes.

    Me: Right. Or, you know, power fails. Or the building catches fire, or is swept away in a natural disaster. Whatevs.

    Me: Actual quote from DBA, during a DR discussion years ago: “But, we’ve never had a disaster *before*!”

    @DaveSchutz You can have multiple drives fail, network errors causing DB corruption, many other problems that muck up your DB.

    @GFritchey It isn’t a book, but here’s why backups are important: https://t.co/IIhMqc6peW

    Thank you, Grant, and thank you, everyone. You’ve illustrated the point perfectly.

    -Jen McCown
    http://www.MidnightDBA.com/Jen

    Sad database? I can help. Email me, or find out more about my consulting at www.MidnightSQL.com!

    Share on TwitterShare on LinkedInShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit
  1. 1
  2. Next ›
  3. Last »