Category: Uncategorized

  • Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. Error source: Microsoft OLE DB Provider for SQL Server – revisited

    This blog post is waiting for me to have some time for the past couple of months by now. It did bite me back then, and so it did yesterday.

    “Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. Error source: Microsoft OLE DB Provider for SQL Server” – now, I must emphasize that I’m not going to reproduce the plethora of info that is present out there already, but instead I might be among the few selected ones that indeed had issues with AD domains. If you’re curious about that, read on; if you’re looking for how to enter some lines of code in some connection string, you better go have a coffee or something.

    Background: the company that I work for, migrated all their SQL Server 2005 servers (with DAS – Direct Attached Storage) to SQL Server 2008 clustering (on SAN). This obviously means a lot (I mean A LOT) of fun, such as deprecated code, and so on. Besides this, one of the required steps is to swap the IP addresses between the SQL Server 2005 machine and the SQL Server 2008 resource on the cluster (of course, anybody knows that SQL Server 2008 is just a resource on a 2008 cluster, right? – I learned this the hard way).

    And now for the fun:

    “ONLY jobs that need to run to C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\DTSRun are failing.
    The ones that are running C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\dtexec are running fine.
    Secondly, the ones running under 80\Tools are the ones using the server IP (10.0.0.31). when you ping the IP address, it still returns SQL03DB as the server.”

    Rough translation of the above: all the jobs that running DTSX packages are running fine, while all the jobs that are running DTS (SQL Server 2000 – yes, I know, that old) are failing in SQL Server 2008. Besides that, when I run ping –a 10.0.0.31, I still get the name of the SQL Server 2005 machine, instead of the SQL Server 2008 cluster resource.

    This is something that happened early May, and I completely forgot about it. And it happened again yesterday.

    Sorry for all that blur stuff, but this is a prod machine. Anyway, as you can see, the IP address of my SQL Server cluster resource is 10.0.0.10.

    Now, if I ping –a 10.0.0.10, I get the following:

    So instead of getting something in the line of “28DBCLU”, I still get the old SQL Server machine, which used to be “01db”.

    Again, oddly enough, this manifested itself only for the DTS packages, which are running DTSRun, found in the \80 folder.

    Solution? A very simple one, just ask the sys admins to make the necessary changes in the DNS (yes, that DNS, related to AD, DHCP, all that jazz). Also, it would be very helpful not to have hard-coded values in your hosts file.

    And for the grand finale: I posted a question on Twitter, under #sqlhelp, asking whether I should have my system databases on SAN (which mean automatic failover in case something goes wrong with the active node), or if they should be on the default installation path (yes, that Program Files thing). While there was a little variation of the answers, my personal choice is to have them automatically fail over. Just imagine what would happen if you have a failover and the msdb
    and master databases are not the same.

    Best regards,
    io

  • My mail to SQL Sentry that will win me (yeah, right) a free seat to SQL Skills training!

    The amazing guys @SQL Sentry (www.sqlsentry.net)  are giving away a chance to win a free seat to SQL Skills Internals and Performance training (check out the details: http://www.sqlsentry.net/sqlskillsimmersion.asp).

    Of course, I decided to give it a try, so I wrote to the guys; you can check it below:

    “Hello there.

    Now, last night at around 2:30 AM I stepped down of bed, as the little ones (we have two kids) kept kicking me in the head for far too long. Since I’m a hopeless DBA, the very first thing to do is to open the laptop and check on the emails. I almost fell down from chair when I saw Paul’s email regarding your offer. And I said to myself ok, I’m still asleep and dreaming, let’s read that again in the morning. Which I did. And there it was, the offer.

    I so MUST HAVE to be there! Let’s see why:

    I live in Romania, which, by all standards, had a strict comunist regime until 1989. While it was strict in regards with computers (we didn’t even have a word for computer), there was a plethora of underground illegal stuff, such as cable TV. This way we got introduced to good movies with hot chicks. Movies that immediately after the Romanian revolution (December 1989 the revolution, early ’90ies for the rest of the story) turned into even more good looking chicks. Of course, the entire gang fell in love with such angels. Even back then we knew that we had no chance with them, but at least we could try to get something similar in Romania.

    By all standards, none of us were quite hot-shots, so we decided that the best way to pick up gorgeous girls is to have money – a truth that happens to be the same worldwide. It also happened that unfortunately all of us were raised to be honest, not to steal, all that jazz, so we realized that we would have to make a career that would pay enough money to stand out from the crowd. There you go, we got into IT.

    This was a big mistake for several reasons: as everywhere else in the world, the true hot shots never go to work, ever; as they say, if you work, you don’t have time to make money. But the worse was to happen: we all fell in love with this new… thing, which was computers. Not to mention that back then the Internet changed it all (yeap, I’m that old, I keep telling that Internet and internet are not the same). So before any of us could realize what’s happening, we pretty much forgot about the movies and the hot chicks and got our hands dirty into all sorts of things, such as networking (myself included) and programming (myself excluded).

    Fast forward a few years later, around the beginning of the millennia, most of us were working in the IT field (by the way, it is still growing exponentially in Romania). Now, there is an old saying: he who can do, will do; he who cannot, will teach. Of course, most of the gang members got to work, while I got to teach (as a technical trainer in various capacities).

    Quick jump into 2008: I got a job offer as a database administrator in SQL Server. Does it have icons? Can I work with a mouse? Yes. OK, I’m in. It was back then when I fell in love with the damn thing. Then I got to read great blogs from great people, such as Brent Ozar and Paul Randal, just to name a few. Back then, I would have said that thanks to them, I kept my love for SQL Server growing.

    Another quick jump into 2011: I got another job as a SQL Server DBA, but this time the mouse was the least of my worries. Just to give you an example: guys, do any of you know anything about clustering? None of us did. OK, you have three days to pick it up, we’re migrating all of our databases to SQL Server 2008 clusters. We did pick it up.

    This year (2012) I got to TechEd Orlando, only to make a fool out of myself in front of Brent Ozar (if you check his presentation, he makes fun of me for asking for a card to show his card to my wife).

    To conclude: while in 2008 I would have said “thanks to these guys…”, this year I’m saying “because of these guys…”. Because of these guys I still love the damn thing (SQL Server, that is). Because of these guys I’m still wasting nights, trying to pick up things on the fly. You cannot imagine the sheer joy and happiness of my wife when I have to work to replace and consolidate the database servers almost every week-end.

    So, if it’s all because of “these guys“, why not let them handle me? At least in part? They made me forget my initial goal, of being a hot shot, and turned me into some sort of a weird kookoo, trying to do his best. Worse part yet; because of them I got again into training, blogging, and trying to help other people.

    I absolutely need this course (and not only): it will massively shorten the path to great knowledge and less work. I’m planning to that ASAP; right now, the kids are still calling me daddy, but with the crazy hours that I have to put, I’m not sure it will be the case in the near future.”

  • Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.

    Another quick one for today:

    When you encounter such an error (see the title and the print screen below), you might want to check this first: http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/b0665753-6bb6-48bb-a938-febc6e942d58

    For the really lazy ones: it’s a clear sign of memory pressure.

    I hope this helps.

    Best regards,
    io

  • BACKUP DATABASE TO DISK = N‘NUL’ – and misconceptions

    Hopefully this will help someone out there.

    There is a command, BACKUP DATBASE <db_name> TO DISK = N’NUL’ and apparently people either don’t know that is there, or are using it for all the wrong purposes.

    We use this particular command to find out our “golden point”, so to speak, which means that we can find out the maximum throughput when taking a backup.

    To give you an example:

    BACKUP
    DATABASE [test] TO DISK = N’K:\FullBackups\test’
    WITH  COPY_ONLY, NOFORMAT, INIT,
    NA
    ME =  N’test-Full Database Backup’,
    SKIP, NOREWIND, NOUNLOAD
    GO

    This gives me, among other things:

    BACKUP DATABASE successfully processed 1931558 pages in 232.509 seconds (63.122 MB/sec).

    Performing the same script as above, but with ‘NUL’:

    BACKUP
    DATABASE [test] TO DISK = N’NUL’
    WITH COPY_ONLY, NOFORMAT, INIT,
    NAME = N’test-Full Database Backup’,
    SKIP, NOREWIND, NOUNLOAD
    GO

     

    And the result:

    BACKUP DATABASE successfully processed 1931206 pages in 103.030 seconds (146.438 MB/sec)

    So you can clearly see that I can actually achieve a higher throughput, namely shorten the time it takes to backup up my database.

    Okay, now that you know what it does, let’s clear some misconceptions about its use:

    • I saw people using it to clear the DCM pages (basically to make their differential backups smaller) – for this one to be achieved, WITH COPY_ONLY will be removed, of course, since this command preserves the LSN chain intact.
      Why on Earth would you want to do it like this to have smaller differential backups? I thought that backup management relates to full, differential and transaction log backups.
    • I heard people using the same backup device (‘NUL’) to clear their transaction logs – huh? WTF…

    To further develop on the two above: as far as SQL Server is concerned, a backup to ‘NUL’ is just that, a backup. It means that the actual write happened as far as SQL Server is concerned. So when performing a classic restore, you need the last full backup, the last differential backup and all (or some) of the transaction log backups.
    But since you wrote to ‘NUL’, there’s no physical presence of the last full backup, so you cannot restore from it. The same goes with the transaction log backups.

    • I saw people doing BACKUP DATABASE TO DISK = N’NUL’ to test their throughput. And they forgot to put WITH COPY_ONLY. Guess what happened:-).

    Ok, so basically this is a useful tool for measuring throughput, but use it wisely. Also, as I just discovered half an hour ago, it works perfectly on my laptop, but not on production, where I have all kinds of activity on the server.

    BACKUP DATABASE successfully processed 1931206 pages in 103.030 seconds (146.438 MB/sec)– backup to ‘NUL’ device
    BACKUP DATABASE successfully processed 1931558 pages in 92.509 seconds (163.122 MB/sec) – COPY_ONLY backup performed to physical disk (on SAN)

    So my “golden spot” is far below the actual speed of the backup. Makes you wonder, isn’t it? J

    I hope this helps.

    Best regards,
    io

  • Tool review – SQL Backup and FTP

    We currently do have a process in place that takes a full backup, creates some zip files, sends the over to another server, and whatever else is left. Obviously, it is prone to errors. Therefore I was more than interested to see this tool in action (as recommended by Pinal Dave).

    Also, I will not bother you how to install the tool, just go to the site, download and install the tool, and also make sure you read the tutorial that appears after the installation is complete.

    What I want to mention, though, is where I think this tool is going: to developers that need a very quick access to a database backup that they can restore on their machines, as well as accidental DBAs that need to take care of small IT shops.

    What I see as drawbacks:

    • No way I can use it with anything else than a full backup (filegroup backups, anyone?)
    • No way I can use it with a VLDB – currently we do have some 1+ TB databases that are giving us nightmares, among other things
    • No way I can catch some tricky errors when talking about backups. Just to give you an example, we just had a failed backup that was not caught in the TRY – CATCH block (see this post).

    What I see as major benefits:

    • Open SSMS locally to have a backup of, say, AdventureWorks? Why? I can easily do it with this tool
    • Scratch my head where should I put my backup? Why? I have a wizard for that, or, better yet, let the sys admin handle it
    • Why buy expensive software that offers me features that I’ll never use?
      Just to give you an example, how many of us have Red Gate’s SQL Backup to have a play with? And HyperBac? What is that? J Kidding, Red Gate, I LOVE YOUR TOOLS!

    As a simple conclusion: if you’re an accidental DBA in charge of a small IT shop, or a developer that needs quick access to a centralized folder will all the backups for either a particular DB or some database backups, this tool is for you. Look no further, it’s more than you’ll ever need.

    As for the rest of us, paranoid DBAs with hundreds of database servers, and TB-sized databases, there are some rumors on the street that soon enough we’ll have a way to teleport our backups to the desired location, all at the speed of light. Oh, wait, that was Star Trek…

    Best regards,
    io

  • Online index operations are fully logged in SQL Server 2008 and later!

    The title is self-explanatory, but I had no idea until I recently saw my transaction log size skyrocketing; and here’s the article: http://support.microsoft.com/kb/2407439

    best regards,
    io

     

  • Is truncate logged or non-logged in SQL Server?

    Okay, second blog post in one day – slowly trying to recoverJ.

    Below is an excerpt from a stored procedure from BizTalk server:

    –If you are doing this we assume it is because you have a huge, old db so it is just faster for us to

        –find things which are not done and hold onto them then the other way around.

        –if we crashed after grabbing these uncompleted instances but before reinserting them, we are okay

        –because we have a unique constraint on the serviceinstanceid identity column so we will just ignore dupes

        –Note that if you run this, you need to have the tracking host stopped so that no new data is being inserted while this runs.

        –This hard purge assumes that inserts have stopped so that we can do unlogged operations like truncate table and not hold locks for

        –long periods of time. Make sure if the system crashes while running this, you get a full clean run before restarting the tracking service or

        –you will end up in a non-deterministic state.

    What struck me was: “This hard purge assumes that inserts have stopped so that we can do unlogged operations like truncate table”. I beg your pardon?

    READ THIS: TRUNCATE TABLE IS LOGGED!!! Okay, to do some justice: it’s minimally logged, which in plain English would roughly translate into the fact that only allocation and de-allocation of pages (that is, data file pages) are logged. But this is another discussion (along with ghost cleanup), so we’ll tackle it some other time.

    Moral of the story: because somebody from Microsoft said so, it doesn’t mean it is soJ.

    Best regards,
    io

  • Fix orphaned users in SQL Server 2005 – not

    A quick one, again (haven’t been blogging for a while, I have like a ton of blogs on my mind, lack the time, though): I think most of the DBAs have stumbled upon “how to fix orphaned users in SQL Server”, right? Well, a quick overview of the script:

    SET
    NOCOUNT
    ON


    SET
    QUOTED_IDENTIFIER
    OFF


    GO

    USE
    <database name>


    GO

    DECLARE @sql varchar(100);

    DECLARE curSQL CURSOR
    FOR

    SELECT
    ‘EXEC
    sp_change_users_login
    “UPDATE_ONE“, “‘+ name + “‘, “‘
    + name +
    “”

    FROM
    sysusers

    WHERE issqluser = 1


    AND
    suser_sname(sid)
    IS
    NULL


    AND name NOT
    IN
    (‘dbo‘, ‘guest‘)

    OPEN curSQL

    FETCH curSQL INTO @sql

    WHILE
    @@FETCH_STATUS
    = 0 BEGIN

    EXEC (@sql)

    PRINT @sql

    FETCH curSQL INTO @sql

    END

    CLOSE curSQL

    DEALLOCATE curSQL


    GO

    So far, so good. Or is it?

    Let’s have a very quick look on what’s under the hood, and for that we’ll actually query the sysusers table.

    select
    uid, name, sid, issqluser from
    sysusers
    :

    and here’s the print screen from my test machine:

    Now, please bear in mind that I don’t want to point anything else, BUT: you can (and actually will) have SQL users that are… well, not SQL Users (that is “issqluser – is set to 0) J. This happens for users associated to logins that are mapped to Windows accounts/groups. I hope this helps.

    Best regards,
    io

  • DTS package runs from command line, but fails from SQL Server Agent

    Yet another quick one for you. One of my colleagues was trying to set up a job to run a DTS package (yeap, I know, a bit of a last century stuff). Whenever he ran the package from the command line, everything was running fine. However, when he ran the same package from within a job, it failed.

    Apparently the answer is very simple in our case, as documented in this article. Just to summarize for you: on a 64-bit system, whenever you run the package from the command line (cmdexec), it calls the 32-bit (x86) version of the tool. Whenever you run it from SQL Server agent, it calls the64-bit of the tool.

    I hope this helps.

    Best regards,
    io

  • How can I tell if my restore process is actually doing something

    Just stumbled into this: if you have a large DB to be restored, it might take forever to actually see the progress moving to 10%, 20%, and so on. Yeah, I know, you should never do a restore from the SSMS, but don’t try to tell me thatJ.
    Anyway, coming back to our scenario: if you have started the restore process, it might take quite a while to see that our particular restore is progressing.
    So here’s a quick look at it:

    SELECT GETDATE() as runtime, command,
      total_elapsed_time,
      percent_complete, estimated_completion_time,
      wait_time, wait_type
      FROM sys.dm_exec_requests
     

    You’ll get a whole bunch of stuff, but we’re going to focus on the “command” part of it, because this is of interest for us:

    As you can see, there’s a RESTORE DATABASE at the second column (command, in our script).

    If I want to focus only on that particular command, I simply add a where clause to the above script:

    WHERE command = 'RESTORE DATABASE'

    Of course, in the percent_complete column I get to see something above 0, if everything is ok.

    I hope this helps.

    Best regards,
    io

    Edit: full article here – as usual, PSSQL team rocks.