Sql Server troubleshooting guide


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Sql Server troubleshooting guide

  1. 1. Troubleshooting GuideProblem No: 1 Connection Timeout Occurs.Solution:Check the server properties. Check the values of Remote Login TimeoutSteps:Go to server properties.Check Advance Tab. Change the value of Remote Login Timeout torequired values. Currently 600 secs.
  2. 2. Problem No: 2 Maximum connections with „sleeping‟ status.Sometimes connection was opened and not closed. Execute this query toget 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 --whereprogram_name like %.Net%ORDER BY spidSolution:Concern the person who has opened connection and ask to close theconnection if unnecessary opened.
  3. 3. Problem No: 3 SQL Server Login Password ExpirationWhen Password Expiry policy on that time password expiration issuecome.Solution:Unclick on Eforce policy and change the password to new password withsa user.
  4. 4. Problem No: 4 Transaction logs not expanded.When Memory of server disk full and transaction log and data filecannot increase by size.Solution:Shrink the Datafiles and transaction logs.Expand the memory of disk(ifpossible).
  5. 5. Problem No: 5 Objects locked by another session. Deadlock occursWhen table is locked by one session and not released it and anothersession goes to wait state untill release by blocked session.Get the Locked Object/Session Details.Sp_lockSample output…spid dbid ObjId IndId Type Resource Mode Status51 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 GRANTSolution:Kill the sessionDeclare @SPID intSET @SPID= --blocked object sessionKill( @SPID)**Note:Be carefull to kill session.
  6. 6. 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 onparticular object.Solution:Provide necessary grant to particular users.
  7. 7. Problem No: 8 Connection Problems with sql server.There is some problem with connecting sql server database fromssms.SQL Error: A network-related or instance-specific error occurred whileestablishing a connection to SQL Server. The server was not found or wasnot accessible. Verify that the instance name is correct and that SQLServer is configured to allow remote connections. (Provider: TCP Provider,error: 0 - No connection could be made because the target machineactively 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 ConfigurationGo to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools>> SQL Server Configuration Manager >> Select TCP/IP
  8. 8. Enable All Protocols except VIA.
  9. 9. Step.4 Enable Remote Connection
  10. 10. Go to Left Tab of Connections and check “Allow remote connections to thisserver”
  11. 11. Step 5. Enable SQL Server Browser Service
  12. 12. 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 aFOREIGN 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 databaseconstraints.EXEC sp_MSforeachtable @command1="ALTER TABLE ? NOCHECKCONSTRAINT ALL"Step 2.Disable Triggers.EXEC sp_MSforeachtable @command1="ALTER TABLE ? DISABLETRIGGER ALL"Step 3.Truncate table.Step 4. Enable triggers and contraints.EXEC sp_MSforeachtable @command1="ALTER TABLE ? CHECKCONSTRAINT ALL"EXEC sp_MSforeachtable @command1="ALTER TABLE ? ENABLETRIGGER ALL"
  13. 13. Problem No: 10 Reset Identity after all table data.When all rows deleted and identity column need to reset to 1.Solution.Use DBCC CHECKIDENTE.gDBCC CHECKIDENT ("dbo.table1");--For Some Specific value.DBCC CHECKIDENT ("dbo.table1”, RESEED, 10);
  14. 14. Problem No: 11 Errors on Modifying Table Definition.When “prevent saving changes that require table re-creation” enable.Solution:Go to Programs SQL Server ManagementStudioToolsOptionsTable and Database DesignersDisable “prevent saving changes that require table re-creation”
  15. 15. Problem No: 12 SQL Server blocked access to STATEMENTOpenRowset/OpenDatasource of component Ad Hoc DistributedQueries because this component is turned off as part of the securityconfiguration for this server.When the sp_configure Ad Hoc Distributed Queries returns 0 in valueSolution:Execute this query…sp_configure Ad Hoc Distributed Queries,1GoReconfigureGo
  16. 16. 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 registeredservers 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:Usersdc_devAppDataLocalTemp2v9fgwzkq.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) atMicrosoft.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, StringdefaultNamespace, 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 toconnect to sql server.Just need to create it again,For E.g.In path C:Usersdc_devAppDataLocalTemp2Folder 2 is missing in it.Create new folder 2 and try to connect it again.