SQL Server Operations

Source: Internet
Author: User
Tags session id rollback time in milliseconds

Encountered the need to operate SQL Server servers, I even command operation will not, Baidu a half-day finally found a can use, although it is not how to use but record a better, or later in the future if you meet and need to check half a day

SELECT * FROM Master. sysprocesses
Query result Field Description

    1. Spid:sql servr Session ID
    2. Kpid:windows thread ID
    3. Blocked: Blocking the plea's session ID. If this column is Null, the identity request is not blocked
    4. Waittype: The waiting resource number for the current connection, indicating whether to wait for the resource, 0 or null indicates no need to wait for any resources
    5. Waittime: Current wait time in milliseconds, 0 means no wait
    6. DBID: The database ID currently being used by the process
    7. UID: User ID to execute the command
    8. Login_time: The time that the client process logs on to the server.
    9. Last_batch: The last time the stored procedure or EXECUTE statement was executed. For system processes, the startup time for SQL Server will be stored
      10.open_tran: The number of open transactions for the process. If there is a nested transaction, it will be greater than 1
      11.Status: Process ID status, dormant = resetting the reply; Running = reply is running one or more batches; Background = reply is running a background task; Rollback = The session is processing a transaction rollback; Pending = reply is waiting for work to become available; runnable = The task in the session is in an executable queue that is waiting to get Scheduler to run; Spinloop = The task in the session is waiting for the spin lock to become available; Suspended = Session is waiting for event to complete
      12.Hostname: Name of the client workstation that establishes the link
      13.program_name: The name of the application, which is the application name in the connection string
      14.Hostprocess: Process ID Number of the connection application in the client workstation
      15.CMD: currently executing command
      16.Loginame: Login Name

Application Examples:

    1. Check if the database is blocked

Find out which Link's blocked field is not 0 first. The blocked field, such as SPID53, is not 0, but 52. The blocked of SPID 52 is 0, so we can conclude that there is a blockage and 53 is blocked by 52. If you find that the value of a connected blocked field equals its own, it means that the connection is doing disk reads and writes, and it waits for its own I/O to finish.

    1. Find links on that database

Check the dbid. Get dbid, you can run the following query to get the name of the database:
Select Name,dbid from Master.sys.sysdatabases
Reference links
Https://www.cnblogs.com/zengkefu/p/6854196.html
Https://jingyan.baidu.com/article/b2c186c820b054c46ff6ff68.html

SQL Server Operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.