Useful system stored procedures in SQL Server

后端 未结 12 835
醉话见心
醉话见心 2021-01-30 03:17

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 Obje

相关标签:
12条回答
  • 2021-01-30 03:47

    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

    0 讨论(0)
  • 2021-01-30 03:47

    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

    0 讨论(0)
  • 2021-01-30 03:48

    Alt + F1 is a good shortcut key for sp_help.

    sp_helptext is another goodie for getting stored procedure text.

    0 讨论(0)
  • 2021-01-30 03:51

    sp_who/sp_who2 - lets you know who is doing what on the server.

    0 讨论(0)
  • 2021-01-30 03:54

    sp_rename

    for renaming database objects (tables, columns, indexes, etc.)

    0 讨论(0)
  • 2021-01-30 04:04
    • sp_who
    • sp_who2
    • sp_helptext

    • list of useful system stored procedures

    0 讨论(0)
提交回复
热议问题