Skip to content

Commit 5191835

Browse files
Some updates...
1 parent 9072c1c commit 5191835

File tree

5 files changed

+109
-4
lines changed

5 files changed

+109
-4
lines changed

Development Application Settings/Red Gate/SQL Prompt/Snippets/cu-c9cc9091-91d1-4966-b4ba-655a34678f4a.json

+1-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"metadata": {
3+
"id": "b9530d2c-850d-46b0-b8b4-51a5899a376e",
4+
"name": "Kevin Martin"
5+
},
6+
"whitespace": {
7+
"wrapLinesLongerThan": 150
8+
},
9+
"lists": {
10+
"placeFirstItemOnNewLine": "always",
11+
"alignSubsequentItemsWithFirstItem": false,
12+
"alignItemsAcrossClauses": false,
13+
"alignAliases": true,
14+
"alignComments": true,
15+
"placeCommasBeforeItems": true,
16+
"addSpaceAfterComma": false
17+
},
18+
"parentheses": {
19+
"parenthesisStyle": "expandedSplit",
20+
"indentParenthesesContents": true,
21+
"collapseParenthesesShorterThan": 35
22+
},
23+
"casing": {
24+
"reservedKeywords": "uppercase",
25+
"builtInFunctions": "uppercase",
26+
"builtInDataTypes": "lowercase",
27+
"useObjectDefinitionCase": true
28+
},
29+
"dml": {
30+
"addNewLineAfterDistinctAndTopClauses": true,
31+
"collapseShortStatements": true,
32+
"collapseStatementsShorterThan": 78,
33+
"collapseShortSubqueries": true,
34+
"collapseSubqueriesShorterThan": 78,
35+
"listItems": {
36+
"placeFromTableOnNewLine": "always",
37+
"placeWhereConditionOnNewLine": "always",
38+
"placeGroupByAndOrderByOnNewLine": "always"
39+
}
40+
},
41+
"ddl": {
42+
"parenthesisStyle": "expandedSplit",
43+
"indentParenthesesContents": true,
44+
"alignDataTypesAndConstraints": true,
45+
"placeConstraintColumnsOnNewLines": "ifLongerOrMultipleColumns",
46+
"indentClauses": true,
47+
"placeFirstProcedureParameterOnNewLine": "always",
48+
"collapseShortStatements": true,
49+
"collapseStatementsShorterThan": 100
50+
},
51+
"controlFlow": {
52+
"indentBeginAndEndKeywords": true,
53+
"collapseStatementsShorterThan": 120
54+
},
55+
"cte": {
56+
"parenthesisStyle": "expandedSplit",
57+
"indentContents": true,
58+
"placeColumnsOnNewLine": true,
59+
"columnAlignment": "indented",
60+
"asAlignment": "rightAligned"
61+
},
62+
"variables": {
63+
"placeAssignedValueOnNewLineIfLongerThanMaxLineLength": false
64+
},
65+
"joinStatements": {
66+
"join": {
67+
"indentJoinTable": false
68+
},
69+
"on": {
70+
"placeOnNewLine": false,
71+
"keywordAlignment": "indented"
72+
}
73+
},
74+
"insertStatements": {
75+
"columns": {
76+
"parenthesisStyle": "compactSimple",
77+
"placeSubsequentColumnsOnNewLines": "ifLongerThanMaxLineLength"
78+
},
79+
"values": {
80+
"parenthesisStyle": "compactSimple",
81+
"indentContents": true,
82+
"placeSubsequentValuesOnNewLines": "ifLongerThanMaxLineLength"
83+
}
84+
},
85+
"caseExpressions": {
86+
"placeExpressionOnNewLine": false,
87+
"placeFirstWhenOnNewLine": "ifInputExpression",
88+
"placeThenOnNewLine": true,
89+
"collapseShortCaseExpressions": true,
90+
"collapseCaseExpressionsShorterThan": 100
91+
},
92+
"operators": {
93+
"comparison": {
94+
"align": true
95+
},
96+
"andOr": {},
97+
"between": {
98+
"placeOnNewLine": false
99+
},
100+
"in": {
101+
"placeFirstValueOnNewLine": "ifLongerThanMaxLineLength"
102+
}
103+
}
104+
}

Development Application Settings/Red Gate/SQL Prompt/Styles/Team Expanded-6d4cd025-b548-497f-bf21-3d5c64111b1f.json

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
},
6666
"joinStatements": {
6767
"join": {
68-
"keywordAlignment": "toTable",
6968
"indentJoinTable": false
7069
},
7170
"on": {

docs/findings/SQLCodeDevelopment.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ This error catching and trowing methodology is the newest. [```THROW```](https:/
15901590
### Return Code Methodology (dbo.TestReturnCode)
15911591
The return code methodology utilizes [```RETURN```](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/return-transact-sql). ```RETURN```, exits unconditionally from a query or procedure. ```RETURN``` is immediate and complete and can be used at any point to exit from a procedure, batch, or statement block. Statements that follow RETURN are not executed.
15921592

1593-
When ```THROW``` is utilized, a return code is not assigned. ```RETURN``` was commonly utilized with [```RAISERROR```](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql) which never aborts execution, so ```RETURN``` could be used afterwards. (See [Using RAISERROR Instead of THROW](/SQL-Server-Development-Assessment/best-practices-and-potential-findings/sql-code-conventions#using-raiserror-instead-of-throw)). Utilizing ```RAISERROR``` with the return code would provide context to the error that occured to present to the user and log the error.
1593+
When ```THROW``` is utilized, a return code is not assigned. ```RETURN``` was commonly utilized with [```RAISERROR```](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql) which never aborts execution, so ```RETURN``` could be used afterwards. (See [Using RAISERROR Instead of THROW](/SQL-Server-Development-Assessment/best-practices-and-potential-findings/sql-code-conventions#using-raiserror-instead-of-throw)). Utilizing ```RAISERROR``` with the return code would provide context to the error that occurred to present to the user and log the error.
15941594

15951595
### Output Parameter Methodology (dbo.TestReturnCodeParameter)
15961596
This methodology utilizes stored procedure ```OUTPUT``` parameters. Here you can set a return code and a return message that is passed back to the software code to present to the user and log the error

docs/findings/TableConventions.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ These are a 400 level tasks and please feel free to reach out to a DBA for assis
543543
## Missing Index for Foreign Key
544544
**Check Id:** 21
545545

546-
Each foreign key in your table should be included in an index. Start off with an index on just the foreign key column if you have no workload to tune a multi-column index. There is a real good chance the indexes will be used when queries join on the parent table.
546+
Each foreign key in your table should be included in an index in the primary key position. If you have a `UNIQUE NONCLUSTERED` index with multiple keys, ensure foreign key columns not in the primary key location also get their own `NONCLUSTERED` index in the primary key position.
547+
548+
Start off with an index on just the foreign key column if you have no workload to tune a multi-column index. There is a real good chance the indexes will be used when queries join on the parent table.
547549

548550
[Back to top](#top)
549551

0 commit comments

Comments
 (0)