|
23 | 23 | ], |
24 | 24 | "description": "Provides standard view comment block" |
25 | 25 | }, |
| 26 | + "Stored Proc Header Comment": { |
| 27 | + "prefix": "sqlCommentProcHeader", |
| 28 | + "body": [ |
| 29 | + "/***************************************************************************************************", |
| 30 | + "Procedure: dbo.usp_DoSomeStuff", |
| 31 | + "GitHub Repo: PADNOS/Salesforce_Extensibility ", |
| 32 | + "Create Date: 2018-01-25", |
| 33 | + "Author: Joe Expert", |
| 34 | + "Description: Verbose description of what the query does goes here. Be specific and don't be", |
| 35 | + "\t\t\t\t\tafraid to say too much. More is better, than less, every single time. Think about", |
| 36 | + "\t\t\t\t\t``what, when, where, how and why`` when authoring a description.", |
| 37 | + "Call by: [schema.usp_ProcThatCallsThis]", |
| 38 | + "\t\t\t\t\t[Application Name]", |
| 39 | + "\t\t\t\t\t[Job]", |
| 40 | + "\t\t\t\t\t[PLC/Interface]", |
| 41 | + "Affected table(s): [schema.TableModifiedByProc1]", |
| 42 | + "\t\t\t\t\t[schema.TableModifiedByProc2]", |
| 43 | + "Used By: Functional Area this is use in, for example, Payroll, Accounting, Finance", |
| 44 | + "Parameter(s): @param1 - description and usage", |
| 45 | + "\t\t\t\t\t@param2 - description and usage", |
| 46 | + "Usage: EXEC dbo.usp_DoSomeStuff", |
| 47 | + "\t\t\t\t\t@param1 = 1,", |
| 48 | + "\t\t\t\t\t@param2 = 3,", |
| 49 | + "\t\t\t\t\t@param3 = 2", |
| 50 | + "\t\t\t\t\tAdditional notes or caveats about this object, like where is can and cannot be run, or", |
| 51 | + "\t\t\t\t\tgotchas to watch for when using it.", |
| 52 | + "****************************************************************************************************", |
| 53 | + "SUMMARY OF CHANGES", |
| 54 | + "Date(yyyy-mm-dd) Author Comments", |
| 55 | + "------------------- ------------------- ------------------------------------------------------------", |
| 56 | + "2012-04-27 John Usdaworkhur Move Z <-> X was done in a single step. Warehouse does not", |
| 57 | + "\t\t\t\t\tallow this. Converted to two step process.", |
| 58 | + "\t\t\t\t\tZ <-> 7 <-> X", |
| 59 | + "\t\t\t\t\t1) move class Z to class 7", |
| 60 | + "\t\t\t\t\t2) move class 7 to class X", |
| 61 | + "", |
| 62 | + "2018-03-22 Maan Widaplan General formatting and added header information.", |
| 63 | + "2018-03-22 Maan Widaplan Added logic to automatically Move G <-> H after 12 months.", |
| 64 | + "***************************************************************************************************/" |
| 65 | + ], |
| 66 | + "description": "Header comment block for stored procs" |
| 67 | + }, |
26 | 68 | "Recent Query": { |
27 | 69 | "prefix": "sqlRecentQuery", |
28 | 70 | "body": [ |
|
65 | 107 | "Create db schema": { |
66 | 108 | "prefix": "sqlCreateSchema", |
67 | 109 | "body": [ |
68 | | - "CREATE SCHEMA [schemaNameHere]", |
69 | | - "GO", |
| 110 | + "CREATE SCHEMA [schemaNameHere];", |
70 | 111 | "", |
71 | 112 | "-- Run this query to see schema", |
72 | 113 | "-- SELECT * FROM sys.schemas;" |
|
77 | 118 | "prefix": "sqlDataTypeInfo", |
78 | 119 | "body": [ |
79 | 120 | "SELECT", |
80 | | - "column_name, data_type, CHARACTER_MAXIMUM_LENGTH, COLLATION_NAME", |
81 | | - "-- distinct TABLE_SCHEMA, TABLE_NAME", |
| 121 | + "\tCOLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLLATION_NAME", |
| 122 | + "\t-- distinct TABLE_SCHEMA, TABLE_NAME", |
82 | 123 | "FROM INFORMATION_SCHEMA.COLUMNS", |
83 | 124 | "WHERE", |
84 | | - "TABLE_SCHEMA IN ('')", |
85 | | - "AND TABLE_NAME IN ('')", |
86 | | - "AND COLUMN_NAME IN ('')" |
| 125 | + "\tTABLE_SCHEMA IN ('')", |
| 126 | + "\tAND TABLE_NAME IN ('')", |
| 127 | + "\tAND COLUMN_NAME IN ('')" |
87 | 128 | ], |
88 | 129 | "description": "What is the collation/data type length for a column?" |
89 | 130 | }, |
|
104 | 145 | "prefix": "sqlMERGE", |
105 | 146 | "body": [ |
106 | 147 | "MERGE target_schema.target_table AS tgt ", |
107 | | - "USING source_schema.staging AS srs ON ( ", |
108 | | - "\tsrs.id = tgt.id ", |
109 | | - ")", |
110 | | - "WHEN MATCHED THEN UPDATE SET ", |
111 | | - "\ttgt.column_name = srs.column_name", |
112 | | - "WHEN NOT MATCHED BY TARGET THEN INSERT ( ", |
113 | | - "\tcolumn_name ", |
114 | | - ")", |
115 | | - "VALUES ( ", |
116 | | - "\tsrs.column_name ", |
117 | | - ")", |
118 | | - "WHEN NOT MATCHED BY SOURCE THEN DELETE;" |
| 148 | + "\tUSING source_schema.staging AS srs ON ( ", |
| 149 | + "\t\tsrs.id = tgt.id ", |
| 150 | + "\t)", |
| 151 | + "\tWHEN MATCHED THEN UPDATE ", |
| 152 | + "\t\tSET ", |
| 153 | + "\t\t\ttgt.column_name = srs.column_name", |
| 154 | + "\tWHEN NOT MATCHED BY TARGET THEN ", |
| 155 | + "\t\tINSERT ( ", |
| 156 | + "\t\t\tcolumn_name ", |
| 157 | + "\t\t)", |
| 158 | + "\t\tVALUES ( ", |
| 159 | + "\t\t\tsrs.column_name ", |
| 160 | + "\t\t)", |
| 161 | + "\tWHEN NOT MATCHED BY SOURCE THEN ", |
| 162 | + "\t\tDELETE", |
| 163 | + ";" |
119 | 164 | ], |
120 | 165 | "description": "MERGE statement syntax" |
121 | 166 | }, |
|
156 | 201 | "prefix": "sqlGrantEXEC", |
157 | 202 | "body": [ |
158 | 203 | "USE database_name;", |
| 204 | + "", |
159 | 205 | "GRANT EXECUTE ON OBJECT::schema.usp_proc_name ", |
160 | | - "\tTO user_name; ", |
161 | | - "GO " |
| 206 | + "\tTO user_name ", |
| 207 | + "; " |
162 | 208 | ], |
163 | 209 | "description": "Grant execute on object to user via t-sql." |
164 | 210 | }, |
|
0 commit comments