?
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