Obtain the SQL statement being executed by the Process

Source: Internet
Author: User
This is an actual problem encountered at work. At that time, Sybase's log space was always full and could not be cleared. We had to restart the Sybase service.
After observation, it is found that there is always a process that occupies log space for a long time and cannot be released. You can only kill the process to find the client where the process is. Program To obtain the SQL statement that the process is executing.
Using the returned SQL statement, the faulty program is located to solve a major bug.

Step 1: Open Sybase Central In the left-side view, double-click the database server name, and then double-click " Login " Folder, select " Add Logon " . Create " Login " , Enter the Login Name: TS , Set the password, and then click Next until the process is complete.

Step 2: Right-click the newly created login name and select"Attribute".

Step 3: select " Role " Page, click " Add role " Button.

Step 4: selectSa_roleAndSybase_ts_roleTwo roles (Press and holdCTRLClick OK to save the settings.

Step 5: OpenSQL advantage.

Step 6: Enter the statementSelect * From syslogsholdIf a record is returned, remember the third field (Spid.

Step 7: EnterSQLStatement:

DBCC traceon (3604)

DBCC sqltext (The value of the Third Field in the previous step.)

Run,The output result is the SQL statement that the process is executing..

Step 8: ExecuteSQLStatement:DBCC traceoff (3604)

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.