{"id":113,"date":"2011-01-18T19:27:00","date_gmt":"2011-01-19T01:27:00","guid":{"rendered":"https:\/\/www.chrystalsander.com\/blog\/?p=113"},"modified":"2023-07-26T12:31:49","modified_gmt":"2023-07-26T17:31:49","slug":"shhh-secret-procedures","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=113","title":{"rendered":"Shhh! Secret Procedures!"},"content":{"rendered":"<p>I don&#8217;t have to tell you that the folks at Microsoft can be quite sneaky so, in case you don&#8217;t already know, there are a number of unofficially documented SQL stored procedures that can make your life not only better, but often cursor-free.<\/p>\n<p>The one that is most helpful to me is entitled &#8220;sp_msforeachtable.&#8221;   Using this stored procedure you can accomplish the same tasks on each table.<\/p>\n<p>You can Google it for more information but a short and simple article can be found at DatabaseJournal.com:<\/p>\n<p><a href=\"http:\/\/www.databasejournal.com\/sqletc\/article.php\/1490991\/Quickly-Disable-Constraint-and-Triggers.htm\" target=\"_blank\" rel=\"noopener\">&#8220;Beginning with version 6.5 of SQL Server, Microsoft provides a stored procedure called sp_MSreachfortable. Using the question mark as a place holder for all table names, the procedure will do the same as the above query in a single line. You can replace the above cursor with this : <\/p>\n<p>sp_MSforeachtable @command1=&#8221;print &#8216;?&#8217; dbcc checktable (&#8216;?&#8217;)&#8221;<\/a><\/p>\n<p>For more handy secrets, do a search on &#8220;undocument sql server stored procedures&#8221; or <a href=\"http:\/\/lmgtfy.com\/?q=undocumented+sql+server+stored+procedures\">http:\/\/lmgtfy.com\/?q=undocumented+sql+server+stored+procedures<\/a> .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t have to tell you that the folks at Microsoft can be quite sneaky so, in case you don&#8217;t already know, there are a number of unofficially documented SQL stored procedures that can make your life not only better, but often cursor-free. The one that is most helpful to me is entitled &#8220;sp_msforeachtable.&#8221; Using &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=113\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Shhh! Secret Procedures!&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[50],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/113"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=113"}],"version-history":[{"count":1,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":184,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions\/184"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}