Skip to main content
Our Tech Ideas

Important & Handy TSQL Commands

TSQL Commands

Space Management TSQL Commands

1)sp_spaceused
2)dbcc sqlperf(logspace)
3)xp_fixeddrives

Information TSQL Commands

1) sp_helpdb
2) select db_id('DBName')
3) select db_name(DBID)
4) select * from sys.dm_exec_sessions, dm_exec_connections
5) select * from sys.databases
6) select * from sys.database_files

Monitoring TSQL Commands

1) sp_who2
2) select * from sys.dm_exec_requests where session_id>50
3) DBCC INPUTBUFFER(spid)
4) fn_get_sql(sqlhandle)
5) DBCC SHOWCONTIG, dm_db_index_physical_stats
6) dbcc opentran