Stored procedures commonly used by SQL Server

Source: Internet
Author: User

?
1. View the version of the database
SELECT @ @version

2. View the machine operating system parameters of the database
EXEC master. xp_msver
To view database-initiated parameters
sp_configure
To view the database startup time
Select CONVERT (varchar (), login_time,120) from master: sysprocesses where spid=1
View all database names and sizes
sp_helpdb
View all database user login information
Sp_helplogins
3. View the size of a data object under a database
sp_spaceused @objname

4. View all stored procedures and functions in the database
Use @database_name
Sp_stored_procedures

sp_help view table structure, stored procedure arguments

5. View the source code of stored procedures and functions
Sp_helptext ' @procedure_name '

or Object_definition (object_id (' sys.sysobjects '))
or select * FROM Sys.system_sql_modules
where object_id = object_id (' sys.sysobjects ')

6. View information about users and processes in the database
sp_who
View information about active users and processes in a SQL Server database
sp_who ' Active '
Look at the SQL statement that the process is executing:
DBCC INPUTBUFFER (51) 51 is a process number

7. View the locks in the SQL Server database
Sp_lock
The process number 1–50 is internal to the SQL Server system, and the process number greater than 50 is the user's connection process. The SPID is the process number, dbid is the database number, and ObjID is the data object number

Stored procedures commonly used by SQL Server

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.