I recently discovered that I could use the sp_help
to get a table definition and have been hooked onto it since then. Before my discovery, I had to open up the Object explorer in SQL Management studio, manually search for the table name, right click on the table and select Design. That was a lot of effort!
What other system stored procedures do you all use that you can't simply live without?
Alt + F1 is a good shortcut key for sp_help
.
sp_helptext
is another goodie for getting stored procedure text.
All of these undocumented ones
xp_getnetname
xp_fileexist
xp_dirtree
xp_subdirs
sp_who2
xp_getfiledetails
xp_fixeddrives
Sp_tempdbspace
xp_enumdsn
xp_enumerrorlogs
sp_MSforeachtable
sp_MSforeachDB
See here: Undocumented stored procedures
And now since SQl Server 2005 all the Dynamic Management Views like sys.dm_db_index_usage_stats
sp_ helpindex [table] - shows you index info (same info as sp_help)
sp_helpconstraint [table] - shows you primary/foreign key/defaults and other constraints *
sp_depends [obj] - shows dependencies of an object, for example:
sp_depends [table] - shows you what stored procs, views, triggers, UDF affect this table
sp_depends [sproc] - shows what tables etc are affected/used by this stored proc
You can use sp_spaceused
to determine the size of a table or the entire database. If you pass the table name, it returns the space used for that table, when called with no argument it gives the space of the database.
sp_catalogs
sp_column_privileges
sp_column_privileges_ex
sp_columns
sp_columns_ex
sp_databases
sp_cursor
sp_cursorclose
sp_cursorexecute
sp_cursorfetch
sp_cursoroption
sp_cursoropen
sp_cursorprepare
sp_cursorprepexec
sp_cursorunprepare
sp_execute
sp_datatype_info
sp_fkeys
sp_foreignkeys
sp_indexes
sp_pkeys
sp_primarykeys
sp_prepare
sp_prepexec
sp_prepexecrpc
sp_unprepare
sp_server_info
sp_special_columns
sp_sproc_columns
sp_statistics
sp_table_privileges
sp_table_privileges_ex
sp_tables
sp_tables_ex
Check This link also
sp_who/sp_who2
- 让您知道谁正在服务器上做什么。
Select * From sysobjects where xtype='U' order by Name
Gives a list of all user-defined tables in a database.
for renaming database objects (tables, columns, indexes, etc.)
master.dbo.xp_cmdshell
I can't list the number of times I didn't have RDP access to a box but did have a SQL login with sufficient permissions to execute that in order to run shell commands on it.
在查询编辑器中突出显示任何proc或其他系统对象名称,然后按shift-f1获取该单词的帮助。
I know it's a rather old topic, but it still has a high rank in search engines.
These are my favorite stored procedures, I hope you find them useful too. Almost all of them can be achieved with a simple command, but these stored procedures perform some checks and validation that is useful.
[sys].[sp_revokelogin]
[sys].[sp_password]
[sys].[sp_MSchangeobjectowner]
[sys].[sp_addlogin]
[sys].[sp_addrole]
[sys].[sp_adduser]
[sys].[sp_denylogin]
[sys].[sp_droplogin]
[sys].[sp_droprole]
[sys].[sp_droprolemember]
[sys].[sp_dropuser]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.