Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Beginning stages of a DR plan for SQL ServerBack to business for the SQL Server community »
    comments

    When you use an undocumented stored procedure, you run the risk of not being able to upgrade your database to a new version. What's worse... you could have broken functionality and not even know it. With undocumented stored procedures, Microsoft may not document when they decide to deprecate it, so you may not know about your broken functionality until it's too late.

    Presented below is a hard coded list of undocumented stored procedures. By their very nature, it is hard to find documentation on undocumented procedures. Therefore, the procedures in the list below is likely to be incomplete.

    How to detect this problem:

    1. Declare @Temp Table(ProcedureName VarChar(50))
    2.  
    3. Insert Into @Temp Values('sp_MStablespace')
    4. Insert Into @Temp Values('sp_who2')
    5. Insert Into @Temp Values('sp_tempdbspace')
    6. Insert Into @Temp Values('sp_MSkilldb')
    7. Insert Into @Temp Values('sp_MSindexspace')
    8. Insert Into @Temp Values('sp_MShelptype')
    9. Insert Into @Temp Values('sp_MShelpindex')
    10. Insert Into @Temp Values('sp_MShelpcolumns')
    11. Insert Into @Temp Values('sp_MSforeachtable')
    12. Insert Into @Temp Values('sp_MSforeachdb')
    13. Insert Into @Temp Values('sp_fixindex')
    14. Insert Into @Temp Values('sp_columns_rowset')
    15. Insert Into @Temp Values('sp_MScheck_uid_owns_anything')
    16. Insert Into @Temp Values('sp_MSgettools_path')
    17. Insert Into @Temp Values('sp_gettypestring')
    18. Insert Into @Temp Values('sp_MSdrop_object')
    19. Insert Into @Temp Values('sp_MSget_qualified_name')
    20. Insert Into @Temp Values('sp_MSgetversion')
    21. Insert Into @Temp Values('xp_dirtree')
    22. Insert Into @Temp Values('xp_subdirs')
    23. Insert Into @Temp Values('xp_enum_oledb_providers')
    24. Insert Into @Temp Values('xp_enumcodepages')
    25. Insert Into @Temp Values('xp_enumdsn')
    26. Insert Into @Temp Values('xp_enumerrorlogs')
    27. Insert Into @Temp Values('xp_enumgroups')
    28. Insert Into @Temp Values('xp_fileexist')
    29. Insert Into @Temp Values('xp_fixeddrives')
    30. Insert Into @Temp Values('xp_getnetname')
    31. Insert Into @Temp Values('xp_readerrorlog')
    32. Insert Into @Temp Values('sp_msdependencies')
    33. Insert Into @Temp Values('xp_qv')
    34. Insert Into @Temp Values('xp_delete_file')
    35. Insert Into @Temp Values('sp_checknames')
    36. Insert Into @Temp Values('sp_enumoledbdatasources')
    37. Insert Into @Temp Values('sp_MS_marksystemobject')
    38. Insert Into @Temp Values('sp_MSaddguidcolumn')
    39. Insert Into @Temp Values('sp_MSaddguidindex')
    40. Insert Into @Temp Values('sp_MSaddlogin_implicit_ntlogin')
    41. Insert Into @Temp Values('sp_MSadduser_implicit_ntlogin')
    42. Insert Into @Temp Values('sp_MSdbuseraccess')
    43. Insert Into @Temp Values('sp_MSdbuserpriv')
    44. Insert Into @Temp Values('sp_MSloginmappings')
    45. Insert Into @Temp Values('sp_MStablekeys')
    46. Insert Into @Temp Values('sp_MStablerefs')
    47. Insert Into @Temp Values('sp_MSuniquetempname')
    48. Insert Into @Temp Values('sp_MSuniqueobjectname')
    49. Insert Into @Temp Values('sp_MSuniquecolname')
    50. Insert Into @Temp Values('sp_MSuniquename')
    51. Insert Into @Temp Values('sp_MSunc_to_drive')
    52. Insert Into @Temp Values('sp_MSis_pk_col')
    53. Insert Into @Temp Values('xp_get_MAPI_default_profile')
    54. Insert Into @Temp Values('xp_get_MAPI_profiles')
    55. Insert Into @Temp Values('xp_regdeletekey')
    56. Insert Into @Temp Values('xp_regdeletevalue')
    57. Insert Into @Temp Values('xp_regread')
    58. Insert Into @Temp Values('xp_regenumvalues')
    59. Insert Into @Temp Values('xp_regaddmultistring')
    60. Insert Into @Temp Values('xp_regremovemultistring')
    61. Insert Into @Temp Values('xp_regwrite')
    62. Insert Into @Temp Values('xp_varbintohexstr')
    63. Insert Into @Temp Values('sp_MSguidtostr')
    64.  
    65. Select Distinct Name
    66. From   sysobjects
    67.        Inner Join @Temp T
    68.          On Object_Definition(id) Like '%' + T.ProcedureName + '%'     
    69. Where  XType = 'P'
    70.        And ObjectProperty(ID, N'IsMSShipped') = 0
    71. Order By Name

    How to correct it: Rewrite your functionality so that is does not rely upon undocumented procedures.

    Level of severity: moderate to high

    Level of difficulty: moderate to high. Undocumented stored procedures are often used because it's easy. Replacing it is usually NOT easy.

    About the Author

    George has been developing software professionally for 19 years, first for the department of defense, and then for various other companies. In 1998, George started his software company, Orbit Software, specializing in School Bus Transportation software. His specialty is refining SQL Server queries to deliver optimal performance.
    Social SitingsTwitterLTD RSS Feed
    Instapaper

    13 comments

    Comment from: Aaron Bertrand [Visitor] · http://sqlblog.com/blogs/aaron_bertrand/
    Aaron Bertrand Here are more:

    xp_qv
    xp_delete_file

    I'd also be curious to see which MS-shipped stored procedures use undocumented stuff, so I would take out the OBJECTPROPERTY clause in that case... not that *I* need to worry about them breaking, since the procs should be fixed by MS during an upgrade if the procs they call have breaking changes. But just for the curiosity factor.
    11/13/09 @ 07:45
    Comment from: George Mastros (gmmastros) [Member]
    George Mastros (gmmastros) Thanks Aaron. I added those 2 undocumented procedures to the list.

    Does anyone else know of other undocumented procedures that should be included in this list?
    11/13/09 @ 07:54
    Comment from: SQLDenis [Member] Email
    SQLDenis Here are 7 more George


    sp_checknames
    sp_enumoledbdatasources
    sp_MS_marksystemobject
    sp_MSaddguidcolumn
    sp_MSaddguidindex
    sp_MSaddlogin_implicit_ntlogin
    sp_MSadduser_implicit_ntlogin
    11/13/09 @ 08:03
    Comment from: George Mastros (gmmastros) [Member]
    George Mastros (gmmastros) Thanks Denis.
    11/13/09 @ 08:08
    Comment from: SQLDenis [Member] Email
    SQLDenis You listed sp_MStablespace twice :-)
    11/13/09 @ 08:09
    Comment from: SQLDenis [Member] Email
    SQLDenis And here are another 5 for you :-)


    sp_MSdbuseraccess
    sp_MSdbuserpriv
    sp_MSloginmappings
    sp_MStablekeys
    sp_MStablerefs
    11/13/09 @ 08:10
    Comment from: SQLDenis [Member] Email
    SQLDenis and just because I can :-) here are 5 more

    sp_MSuniquetempname
    sp_MSuniqueobjectname
    sp_MSuniquecolname
    sp_MSuniquename
    sp_MSunc_to_drive
    11/13/09 @ 08:13
    Comment from: SQLDenis [Member] Email
    SQLDenis Okay after this I WILL stop, 9 more

    xp_get_MAPI_default_profile
    xp_get_MAPI_profiles

    xp_regdeletekey
    xp_regdeletevalue
    xp_regread
    xp_regenumvalues
    xp_regaddmultistring
    xp_regremovemultistring
    xp_regwrite
    11/13/09 @ 08:31
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky sp_makewebtask
    11/17/09 @ 07:32
    Comment from: SQLDenis [Member] Email
    SQLDenis Naomi,

    sp_makewebtask is in books on line

    http://msdn.microsoft.com/en-us/library/aa238843%28SQL.80%29.aspx

    as well as sp_runwebtask
    11/17/09 @ 10:16
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky But it's deprecated, as I understood. In other words, even documented SPs may become deprecated.
    11/17/09 @ 11:45
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky Check this article Undocumented stored procedures on the same topic.

    You can also run sp_help on master database to find lots of undocumented functions and procedures
    11/20/09 @ 05:58
    Comment from: Naomi Nosonovsky [Member]
    Naomi Nosonovsky What will you use instead of xp_fixeddrives ?
    12/28/09 @ 09:52

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)