2

I am having some trouble diagnosing the cause of a problem I am having with Microsoft SQL Server 2008 R2.

There is an application written in C#.net that connects to the database.

Occasionally the application will throw this error:

Cannot open database "<database name>" requested by the login. The login failed.
Login failed for user '<user name>'.

I can successfully connect to the database through SQL Server Management Studio by copying and pasting the login information from my connection string in Web.config

Looking at the SQL Server log, this is the error that comes up:

Source      Message

Logon       Login failed for user '<user name>'. Reason: Failed to open the explicitly specified database.
Logon       Error: 18456 Severity: 14 State: 38.

Looking up that error code online doesn't provide any solutions. The recommendation is to run a trace using SQL Server Profiler and wait for the problem to happen.

I ran the trace and noticed that the following happens every time the error occurs (some lines removed for privacy reasons, click to enlarge):

sql trace

When the last item happens, this error message opens:

Failed to read trace data

I looked in the SQL Server Agent Jobs tree in SQL Server Management Studio and noticed some jobs in there that I created but don't use any more. I removed them and the error still comes up.

The only job left in there is:

  • syspolicy_purge_history

Which I assume are required to some extent.

Does anyone know how to fix this problem? What steps can I take to find and resolve the issue?

Detailed Version Info:

Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)   Jun 28 2012 08:36:30   Copyright (c) Microsoft Corporation  Web Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor) 
2
  • Is auto close ON on the database ?
    – Kin Shah
    Commented Apr 24, 2014 at 16:27
  • @kin Auto close is off for everything
    – zoplonix
    Commented Apr 24, 2014 at 16:56

1 Answer 1

1

Is the error you see on that last line always preceded by the same set of jobs, or does the error happen in different places?

I've thought about this for the last half hour and everything I think of I can refute. Do you have any known networking issues on this server? I've seen something kind of like this with VMWare's networking stack being flaky and dropping connections. But then that doesn't make sense because the SQL box is showing an error.

Even though I ask about networking, I can come up with refutations to that, too. This is a tough one.

If the jobs listed above are the culprit, then I would need to see what they are doing be sure what was going on.

12
  • Yes it is always the same set of jobs. See my related question here: dba.stackexchange.com/questions/63855/… maybe we can work this out in chat
    – zoplonix
    Commented Apr 24, 2014 at 19:42
  • It kind of looks like SQL Server agent is restarting every X minutes. The generic refresher launches every time Agent launches. Can you disable the set of jobs in Agent? I'm not sure what they do for you.
    – ACDBA
    Commented Apr 24, 2014 at 21:00
  • I have removed all of the jobs in Agent. The SQL Server agent service has been disabled. The error still comes up
    – zoplonix
    Commented Apr 25, 2014 at 14:26
  • What does the trace look like?
    – ACDBA
    Commented Apr 25, 2014 at 15:39
  • What if you run the trace without the GUI and then after the error go in and stop it and see the file output? If there is anything with networking going on, it should not stop the trace if you are running it in this way. blogs.msdn.com/b/sqlsecurity/archive/2008/12/12/…
    – ACDBA
    Commented Apr 25, 2014 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.