18
Troubleshooting Guide Problem No: 1 Connection Timeout Occurs. Solution: Check the server properties. Check the values of Remote Login Timeout Steps: Go to server properties. Check Advance Tab. Change the value of Remote Login Timeout to required values. Currently 600 secs.

Sql Server troubleshooting guide

Embed Size (px)

Citation preview

Page 1: Sql Server troubleshooting guide

Troubleshooting Guide

Problem No: 1 Connection Timeout Occurs.

Solution:

Check the server properties. Check the values of Remote Login Timeout

Steps:

Go to server properties.

Check Advance Tab. Change the value of Remote Login Timeout to required values. Currently 600 secs.

Page 2: Sql Server troubleshooting guide

Problem No: 2 Maximum connections with ‘sleeping’ status.

Sometimes connection was opened and not closed. Execute this query to get details.

sp_who ‘UserName’

SELECT spid,login_time, master.dbo.sysprocesses.status, hostname, program_name, cmd, cpu, physical_io, blocked, master.dbo.sysdatabases.name, loginame FROM master.dbo.sysprocesses INNER JOIN master.dbo.sysdatabases ON sys.sysprocesses.dbid = sys.sysdatabases.dbid --where program_name like '%.Net%' ORDER BY spid

Solution:

Concern the person who has opened connection and ask to close the connection if unnecessary opened.

Page 3: Sql Server troubleshooting guide

Problem No: 3 SQL Server Login Password Expiration

When Password Expiry policy on that time password expiration issue come.

Solution:

Unclick on Eforce policy and change the password to new password with sa user.

Page 4: Sql Server troubleshooting guide

Problem No: 4 Transaction logs not expanded.

When Memory of server disk full and transaction log and data file cannot increase by size.

Solution:

Shrink the Datafiles and transaction logs.Expand the memory of disk(if possible).

Page 5: Sql Server troubleshooting guide

Problem No: 5 Objects locked by another session. Deadlock occurs

When table is locked by one session and not released it and another session goes to wait state untill release by blocked session.

Get the Locked Object/Session Details.

Sp_lock

Sample output…

spid dbid ObjId IndId Type Resource ModeStatus51 4 0 0 DB S GRANT53 15 0 0 DB S GRANT54 5 0 0 DB S GRANT55 18 0 0 DB S GRANT56 18 0 0 DB S GRANT56 14 0 0 DB S GRANT56 18 1114487049 0 TAB Sch-S

GRANT56 14 946102411 0 PAG 1:4236 IS

GRANT56 18 440388638 0 TAB IS GRANT56 14 1845581613 20 PAG 1:249589 S

GRANT

Solution:

Kill the session

Declare @SPID int

SET @SPID= --blocked object session

Kill( @SPID)

**Note:Be carefull to kill session.

Page 6: Sql Server troubleshooting guide

Problem No: 6 Deleted Table Data.

When Developers deleted some data by mistake.

Solution:

Get Data from Backup file.

Restore it to some other database. Get Deleted data from restored backup.

Problem No: 7 Permission Denied on some operation.

Sometime all users don’t have privileges to do all operation on particular object.

Solution:

Provide necessary grant to particular users.

Page 7: Sql Server troubleshooting guide

Problem No: 8 Connection Problems with sql server.

There is some problem with connecting sql server database from ssms.

SQL Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (Provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) (Microsoft SQL Server, Error: 10061)

Solution:

Steps to follow.

Step.1 Check the connection information.

Instance Name, Username and password.

Step.2 Check the services of sql server running.

Step.3 Enable TCP/IP in SQL Server Configuration

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP

Page 8: Sql Server troubleshooting guide

Enable All Protocols except VIA.

Page 9: Sql Server troubleshooting guide

Step.4 Enable Remote Connection

Page 10: Sql Server troubleshooting guide

Go to Left Tab of Connections and check “Allow remote connections to this server”

Page 11: Sql Server troubleshooting guide

Step 5. Enable SQL Server Browser Service

Page 12: Sql Server troubleshooting guide

Problem No: 9 cannot truncate table.Foregn Key reference.

When need to truncate table but got the error of foreign key violation.

SQL Error: Cannot truncate table 'dbo.tNewsPaper' because it is being referenced by a FOREIGN KEY constraint.

Solution:

There is need to disable contraints and triggers on table.

Steps to follow.

Step 1.Disable Named foreign key contraints or disable all database constraints.

EXEC sp_MSforeachtable @command1="ALTER TABLE ? NOCHECK CONSTRAINT ALL"

Step 2.Disable Triggers.

EXEC sp_MSforeachtable @command1="ALTER TABLE ? DISABLE TRIGGER ALL"

Step 3.Truncate table.

Step 4. Enable triggers and contraints.

EXEC sp_MSforeachtable @command1="ALTER TABLE ? CHECK CONSTRAINT ALL"

EXEC sp_MSforeachtable @command1="ALTER TABLE ? ENABLE TRIGGER ALL"

Page 13: Sql Server troubleshooting guide

Problem No: 10 Reset Identity after all table data.

When all rows deleted and identity column need to reset to 1.

Solution.

Use DBCC CHECKIDENT

E.g

DBCC CHECKIDENT ("dbo.table1");

--For Some Specific value.

DBCC CHECKIDENT ("dbo.table1”, RESEED, 10);

Page 14: Sql Server troubleshooting guide

Problem No: 11 Errors on Modifying Table Definition.

When “prevent saving changes that require table re-creation” enable.

Solution:

Go to Programs SQL Server Management StudioToolsOptionsTable and Database DesignersDisable “prevent saving changes that require table re-creation”

Page 15: Sql Server troubleshooting guide

Problem No: 12 SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server.

When the sp_configure 'Ad Hoc Distributed Queries' returns 0 in value

Solution:

Execute this query…

sp_configure 'Ad Hoc Distributed Queries',1

Go

Reconfigure

Go

Page 16: Sql Server troubleshooting guide

Problem No: 13 Value cannot be null. Parameter name: viewInfo (Microsoft.SqlServer.Management.SqlStudio.Explorer).

When try to connect sql server from Management studio.

Error Description:

Microsoft.SqlServer.Management.RegisteredServers.RegisteredServerException: Unable to read the list of previously registered servers on this system. Re-register your servers in the 'Registered Servers' window. ---> Microsoft.SqlServer.Management.Sdk.Sfc.SfcSerializationException: Deserialization operation on /RegisteredServersStore/ServerGroup/CentralManagementServerGroup has failed. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\dc_dev\AppData\Local\Temp\2\v9fgwzkq.tmp'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated() at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile) at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension) at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources) at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources) at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources) at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence) at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies) at System.Xml.Serialization.TempAssembly..ctor(

Solution:

Sometime in temp folder some folder removed by us and it needed to connect to sql server.

Just need to create it again,

For E.g.

In path 'C:\Users\dc_dev\AppData\Local\Temp\2\

Folder 2 is missing in it.

Create new folder 2 and try to connect it again.