|
| 1 | +# Microsoft SQL Server Stored Procedure |
| 2 | +[SQL Server Name Convention and T-SQL Programming Style](https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Name%20Convention%20and%20T-SQL%20Programming%20Style.md) |
| 3 | + |
| 4 | +Start all procedure from if exist statement: |
| 5 | +```sql |
| 6 | +IF OBJECT_ID('dbo.ProcedureName', 'P') IS NULL |
| 7 | +EXECUTE ('CREATE PROCEDURE dbo.ProcedureName AS SELECT 1'); |
| 8 | +GO |
| 9 | + |
| 10 | + |
| 11 | +ALTER PROCEDURE dbo.usp_ProcedureName( |
| 12 | +``` |
| 13 | +It helps to save all grants for procedure (analog `CREATE OR REPLACE PROCEDURE` in [Oracle](http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6009.htm 'Offical Oracle Documentation')). |
| 14 | + |
| 15 | + |
| 16 | +## [sp_IndexAnalysis-v11](sp_IndexAnalysis-v11.sql) |
| 17 | +Author: Jason Strate<br/> |
| 18 | +Original link: http://www.jasonstrate.com/2013/05/index-analysis-may-update/<br/> |
| 19 | +Tested on SQL Server version: 2012/2014 |
| 20 | + |
| 21 | + |
| 22 | +## [sp_RestoreGene](sp_RestoreGene.sql) |
| 23 | +Author: Andy Yun<br/> |
| 24 | +Original link: https://sqlbek.wordpress.com/2015/03/04/sp_helpexpandview-well-i-didnt-expect-that/<br/> |
| 25 | +Tested on SQL Server version: 2008/2012/2014 |
| 26 | + |
| 27 | + |
| 28 | +## [sp_RestoreGene](sp_RestoreGene.sql) |
| 29 | +Author: Paul Brewer<br/> |
| 30 | +Original link: https://paulbrewer.wordpress.com/sp_restoregene/<br/> |
| 31 | +Tested on SQL Server version: 2008/2012/2014 |
| 32 | + |
| 33 | + |
| 34 | +## [usp_GetUntrustedForeignKeys](usp_GetUntrustedForeignKeys.sql) |
| 35 | +Author: Jefferson Elias<br/> |
| 36 | +Original link: http://www.sqlshack.com/managing-untrusted-foreign-keys/<br/> |
| 37 | +Tested on SQL Server version: 2008/2012/2014 |
| 38 | + |
| 39 | + |
| 40 | +## [usp_RunCheckAllUntrustedForeignKeys](usp_RunCheckAllUntrustedForeignKeys.sql) |
| 41 | +Author: Jefferson Elias<br/> |
| 42 | +Original link: http://www.sqlshack.com/managing-untrusted-foreign-keys/<br/> |
| 43 | +Tested on SQL Server version: 2008/2012/2014 |
| 44 | + |
| 45 | + |
| 46 | +## [sp_capture_login_auth](sp_capture_login_auth.sql) |
| 47 | +Author: Unknown<br/> |
| 48 | +Original link: Unknown<br/> |
| 49 | +Tested on SQL Server version: 2012/2014 |
| 50 | + |
| 51 | + |
| 52 | +## [sp_Blocked_Process_Report_Viewer](sp_blocked_process_report_viewer.sql) |
| 53 | +Author: Michael J. Swart<br/> |
| 54 | +Original link: https://sqlblockedprocesses.codeplex.com/<br/> |
| 55 | +Tested on SQL Server version: 2012/2014 |
| 56 | + |
| 57 | + |
| 58 | +## [sp_sqltrace](sp_sqltrace.sql) |
| 59 | +Author: Erland Sommarskog<br/> |
| 60 | +Original link: http://www.sommarskog.se/sqlutil/sqltrace.html<br/> |
| 61 | +Tested on SQL Server version: 2005/2008/2012/2014 |
| 62 | + |
| 63 | + |
| 64 | +## [usp_BulkUpload](usp_BulkUpload.sql) |
| 65 | +Author: Konstantin Taranov<br/> |
| 66 | +Original link: None<br/> |
| 67 | +Tested on SQL Server version: 2012/2014 |
| 68 | + |
| 69 | + |
| 70 | +## [usp_EnableAndAddFileStreamForDatabase](usp_EnableAndAddFileStreamForDatabase.sql) |
| 71 | +Author: Unknown<br/> |
| 72 | +Original link: None<br/> |
| 73 | +Tested on SQL Server version: 2008/2012 |
| 74 | + |
| 75 | + |
| 76 | +## [usp_FindDbObjects](usp_FindDbObjects) |
| 77 | +Author: Unknown<br/> |
| 78 | +Original link: None<br/> |
| 79 | +Tested on SQL Server version: 2008/2012/2014 |
| 80 | + |
| 81 | + |
| 82 | +## [usp_LogError](usp_LogError.sql) |
| 83 | +Author: Unknown<br/> |
| 84 | +Original link: None<br/> |
| 85 | +Tested on SQL Server version: 2008/2012/2014 |
| 86 | + |
| 87 | + |
| 88 | +## [usp_Object_Search](usp_Object_Search.sql) |
| 89 | +Author: Sean Smith<br/> |
| 90 | +Original link: http://www.sqlservercentral.com/scripts/object/66798/<br/> |
| 91 | +Tested on SQL Server version: 2008/2012/2014 |
| 92 | + |
| 93 | + |
| 94 | +## [usp_PrintDebug](usp_PrintDebug.sql) |
| 95 | +Author: Unknown<br/> |
| 96 | +Original link: None<br/> |
| 97 | +Tested on SQL Server version: 2008/2012/2014 |
| 98 | + |
| 99 | + |
| 100 | +## [usp_PrintError](usp_PrintError.sql) |
| 101 | +Author: Microsoft<br/> |
| 102 | +Original link: None<br/> |
| 103 | +Tested on SQL Server version: 2008/2012/2014 |
| 104 | + |
| 105 | + |
| 106 | +## [usp_RandomWait](usp_RandomWait.sql) |
| 107 | +Author: Unknown<br/> |
| 108 | +Original link: None<br/> |
| 109 | +Tested on SQL Server version: 2008/2012/2014 |
| 110 | + |
| 111 | + |
| 112 | +## [usp_SQL_Server_System_Report](usp_SQL_Server_System_Report.sql) |
| 113 | +Author: Sean Smith<br /> |
| 114 | +Original link: <http://www.sqlservercentral.com/scripts/Administration/70243/><br /> |
| 115 | +Tested on SQL Server version: 2008/2012/2014 |
| 116 | + |
| 117 | + |
| 118 | +## [usp_SearchOnAllDB](usp_SearchOnAllDB.sql) |
| 119 | +Author: David Musgrave<br /> |
| 120 | +Original link: None<br /> |
| 121 | +Tested on SQL Server version: 2008/2012/2014 |
| 122 | + |
| 123 | + |
| 124 | +## [usp_String_Search](usp_String_Search.sql) |
| 125 | +Author: Sean Smith<br /> |
| 126 | +Original link: None<br /> |
| 127 | +Tested on SQL Server version: 2008/2012/2014 |
| 128 | + |
| 129 | + |
| 130 | +## [usp_TableUnpivot](usp_TableUnpivot.sql) |
| 131 | +Author: Konstantin Taranov<br/> |
| 132 | +Original link: None<br/> |
| 133 | +Tested on SQL Server version: 2012/2014 |
| 134 | + |
| 135 | + |
| 136 | +## [usp_UnusedInputParameters](usp_UnusedInputParameters.sql) |
| 137 | +Author: Sean Smith<br/> |
| 138 | +Original link: None<br/> |
| 139 | +Tested on SQL Server version: 2008/2012/2014 |
| 140 | + |
| 141 | + |
| 142 | +## [usp_bcpTableUnload](usp_bcpTableUnload.sql) |
| 143 | +Author: Konstantin Taranov<br/> |
| 144 | +Original link: None<br/> |
| 145 | +Tested on SQL Server version: 2012/2014 |
| 146 | + |
| 147 | + |
| 148 | +## [usp_bcpTableUnloadBatchMode](usp_bcpTableUnloadBatchMode.sql) |
| 149 | +Author: Konstantin Taranov<br/> |
| 150 | +Original link: None<br/> |
| 151 | +Tested on SQL Server version: 2012/2014 |
| 152 | + |
| 153 | + |
| 154 | +## [usp_bcpUnloadSelect](usp_bcpUnloadSelect.sql) |
| 155 | +Author: Konstantin Taranov<br/> |
| 156 | +Original link: None<br/> |
| 157 | +Tested on SQL Server version: 2012/2014 |
| 158 | + |
| 159 | + |
| 160 | +## [usp_who5](usp_who5.sql) |
| 161 | +Author: Sean Smith<br /> |
| 162 | +Original link: http://wwwservercentral.com/scripts/sp_who/68607/<br /> |
| 163 | +Tested on SQL Server version: 2012/2014 |
| 164 | + |
| 165 | + |
| 166 | +## [usp_PrintString](usp_PrintString.sql) |
| 167 | +Author: John Huang<br /> |
| 168 | +Original link: http://www.sqlservercentral.com/blogs/john-huangs-blog/2015/11/19/print-long-string/<br /> |
| 169 | +Tested on SQL Server version: 2014 |
| 170 | + |
| 171 | + |
| 172 | +## [usp_Generate_Merge](usp_Generate_Merge.sql) |
| 173 | +Author: Narayana Vyas Kondreddi<br/> |
| 174 | +Original link: https://github.com/SQLauto/generate-sql-merge/blob/master/master.dbo.sp_generate_merge.sql<br /> |
| 175 | +Tested on SQL Server version: 2008/2012/2014 |
| 176 | + |
| 177 | + |
| 178 | +## [usp_Generate_Merge](usp_SSIS_ScriptEnvironment.sql) |
| 179 | +Author: Jeff Jordan<br/> |
| 180 | +Original link: http://www.sqlservercentral.com/articles/Integration+Services+%28SSIS%29/135173/<br /> |
| 181 | +Tested on SQL Server version: 2012/2014 |
| 182 | + |
| 183 | + |
| 184 | +## [usp_SQLskillsAnalyzeLog](usp_SQLskillsAnalyzeLog.sql) |
| 185 | +Author: Paul S. Randal<br/> |
| 186 | +Original link: http://www.sqlskills.com/blogs/paul/code-to-analyze-the-transaction-hierarchy-in-the-log/<br /> |
| 187 | +Tested on SQL Server version: 2012/2014 |
| 188 | + |
| 189 | + |
| 190 | +## [usp_CreatePlantUMLCode](usp_CreatePlantUMLCode.sql) |
| 191 | +Author: Phil Factor<br/> |
| 192 | +Original link: https://www.simple-talk.com/sql/sql-tools/automatically-creating-uml-database-diagrams-for-sql-server/<br /> |
| 193 | +Tested on SQL Server version: 2012/2014 |
0 commit comments