Tag: syndicated

  • SQL Server Needs Tempdb

    I saw a post recently where someone noted they had moved tempdb like this:

    USE master; GO ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'c:\tempdb.mdf'); GO ALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = 'c:\templog.ldf')

    This gives you the message the tempdb has been moved, and it will take effect on restart. If you restart, however, you’ll often find the service doesn’t restart and you get a “network error” when you try to connect. This is because the service is down.

    If you check the error log, you might see this:

    2013-07-05 13:20:48.65 spid9s      Clearing tempdb database.

    2013-07-05 13:20:48.65 spid9s      Error: 5123, Severity: 16, State: 1.

    2013-07-05 13:20:48.65 spid9s      CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘c:\tempdb.mdf’.

    2013-07-05 13:20:48.65 spid9s      Error: 17204, Severity: 16, State: 1.

    2013-07-05 13:20:48.65 spid9s      FCB::Open failed: Could not open file c:\tempdb.mdf for file number 1.  OS error: 2(The system cannot find the file specified.).

    2013-07-05 13:20:48.65 spid9s      Error: 5120, Severity: 16, State: 101.

    2013-07-05 13:20:48.65 spid9s      Unable to open the physical file "c:\tempdb.mdf". Operating system error 2: "2(The system cannot find the file specified.)".

    2013-07-05 13:20:48.65 spid9s      Error: 1802, Severity: 16, State: 4.

    2013-07-05 13:20:48.65 spid9s      CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

    You might also see an operating system error 5 (access is denied) if the files exist. In all likelihood, the problem is security for your service account. The SQL Server service account shouldn’t have rights to all folders and files on the system. If it does, you’re doing something wrong.

    I had thought (incorrectly) that SQL might start, but be in a read-only state without tempdb. However Gail Shaw pointed out this was incorrect, and when I tested this, she was right. SQL Server won’t start.

    What can you do?

    A few options here.

    • The brute force approach
    • The more elegant approach

    The more elegant approach is specified in Books Online, in Move System Databases. In the failure recovery procedure, you start SQL Server with Trace Flag 3608, issue the alter commands, and then restart the instance without the trace flag.

    The brute force approach, which I have tested, is to move the tempdb files to this location (they didn’t exist in my situation). You’ll need admin permissions to do this. You can then change the service account to one with permissions to see the files (like an admin), and restart the instance. From there, connect, and issue the ALTER DATABASE commands as shown above, with the correct path.

    If you need help configuring permissions, use this article.

  • Two Weeks until SQL Saturday #222 in Sacramento

    It’s just two weeks until my next trip. It feels like I just got back from London, and one again I’m prepping to leave again. This is my only trip in July, which I appreciate. It’s been a busy year so far, with lots of travel for me and I am glad to have a little downtime.

    This trip is a mix of vacation and work. I’ll be heading out early as Red Gate has a mini-SQL in the City event on Friday. We’re trying to get customers to come, but if there is space next week, I’ll send out a registration link. I speak Saturday and then head back to San Francisco. My daughter is joining me on this trip, with the chance to tour the NoCal area for the first time. She was actually here with me when she was 1, but didn’t remember that trip.

    I’m presenting my talk on searching binary data, which I’ve done a few times in the last year. This one will be a look at how you get information out of office documents from within SQL Server. It’s a neat feature for the product, and I’d like to hear how people are using it. Let me know if you are, or if I convince you to try it.

    I’ve also got a joint presentation with Grant Fritchey on A Day in the Life of a DBA, showing the common problems you face and a few ways Red Gate can make your job easier.

    I’m looking forward to a Sun/Mon/Tue vacation, getting some time off and recharging before I have a busy fall with the US SQL in the City tour.

  • Test Your Restores

    Test your restores: he first tip in my Hard Earned Lessons of a DBA piece.

    I can’t emphasize this enough. I’ve been called in as an employee and consultant to companies that never had tested a restore. Quite a few of those times there has been data loss.

  • T-SQL Tuesday #44–Second Chances

    tsqltuesdayIt’s T-SQL Tuesday time again. This is the monthly blog party, started by Adam Machanic. If you’d like to participate, write a post on the topic and publish it on the second Tuesday of the month. If you’d like to host, contact Adam.

    This month the topic is hosted by Bradley Ball and his subject is Second Chances.

    Second Chances

    We all make mistakes. I ask the question of people in some of my talks, and note that I make mistakes all the time. I do, and while most of them are fairly small and easily recovered from, some aren’t. Some are easy to brush off, and some are very, very embarrassing.

    In my career, when I think about the big mistakes I’ve made, I’ve got a few choices. There have been times I’ve deleted all the data in a table.

    secondchance

    There have been times I’ve restarted a SQL Server without telling anyone. There have been “fixes” to the system I’ve made without running through the proper channels. However there is one item that stands out for a few reasons.

    SQL Slammer

    I’d let patching slip. We had a large SQL Server environment (hundreds of Standard/Enterprise versions, thousands of MSDE versions) and while we’d been trying to stay patched, it was a hassle and we let some things slip in the fall of 2002.

    I’d gone to the mountains for the weekend to ski with my family. We returned late on a Sunday night to find numerous voice mail messages at home and on my cell phone. I was actually called again while I was checking messages on the way home from a friend at work that said I needed to come in. After dropping off my wife and kids, I headed to the office.

    Our analysis of the worm showed that it was wrecking havoc on our network. It constantly bottlenecked the network, and we had shut everything down. For a 5,000 person company, with a central network presence and hundred of software developers, this was not ideal. We were up most of the night, waiting on someone from Microsoft to fly in and help us rebuild the patch that Microsoft had released. Since we’d installed many instances of MSDE in non-standard locations, the patches wouldn’t work.

    Our network was down Mon and Tues, but we learned some valuable lessons, like email and file shares weren’t so critical to the business that we couldn’t function for a day. We also learned that allowing developers to ignore patches was a bad idea as the majority of the delays after Mon afternoon were due to MSDE instances.

    My lesson? Myself and the other DBA received a stern talking to from our boss about patching. We had delayed some of the patches for a few months, but there wasn’t a good excuse for getting almost six months behind. Microsoft had been sending lots of patches, but we didn’t have a good reason for not getting them installed quarterly.

    I still don’t like the every other month patches that MS releases as cumulative updates, and I don’t recommend them, but I have learned the security updates are worth getting installed ASAP.