You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-11Lines changed: 35 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,48 @@
1
1
# SQL Server Assess Overview
2
2
The SQL Server Assess project contains the [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) stored procedure. It can be used by database developers, software developers and for performing database code (smell) reviews.
3
3
4
-
This lists the database development best practice checks and naming conventions checks for the stored procedure named sp_Develop.
4
+
This lists the database development best practice checks and naming conventions checks for the stored procedure named [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql).
5
5
6
6
## sp_Develop Install Instructions
7
7
8
8
It is recommend installing the [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) stored procedures in the master database for full SQL Servers, but if you want to use another one, that's totally fine.
9
9
10
-
On Azure SQL Server you will need to install the sp_Develop stored procedure in the user database.
10
+
On Azure SQL Server you will need to install the [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) stored procedure in the user database.
11
11
12
12
## sp_Develop Usage Instructions
13
13
14
-
After installing the [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) stored procedure open SSMS and run in the database you wish to check for database development best practices.
14
+
After installing the [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) stored procedure open SQL Server Management Studio and run in the database you wish to check for database development best practices.
15
15
16
16
```sql
17
17
EXEC dbo.sp_Develop
18
18
```
19
19
20
20
[Check out the parameter section for more options](#Parameter-Explanations)
21
21
22
+
## sp_Develop Results
23
+
24
+
After running [sp_Develop](https://github.com/EmergentSoftware/SQL-Server-Assess/blob/master/sp_Develop.sql) the 'Results' tab will contain the checks findings.
The findings results are order by DatabaseName, SchemaName, ObjectName, ObjectType, FindingGroup, Finding. This allows you to review all the checks for an object at the same time.
29
+
30
+
#### Column Results Details
31
+
32
+
|Column Name|Details|
33
+
|--|--|
34
+
|DatabaseName|Can be run for multiple databases so this will show you the database with the potential issue|
35
+
|SchemaName|This is the schema for the object that might have an issue|
36
+
|ObjectName|This can be anything from user tables, views stored procedures, functions, …|
37
+
|FindingGroup|The high level grouping for the check<br/> - Naming Conventions<br/>- Table Conventions<br/>- Data Type Conventions<br/>- SQL Code Development<br/>- Running Issues|
38
+
|Finding|The specific potential issue we the check is looking for|
39
+
|Details|Additional details about the potential issue. This does not go into in-depth details of the potential issue but should give you a heads up of what to look for.|
40
+
|URL|Copy and paste this link into a browser to view the README.md write up for the potential issue|
41
+
|SkipCheckTSQL|In this column you will find a generated TSQL script INSERT |
42
+
|Priority|The lower the number the more severe the potential issue is to address|
43
+
|CheckId|Every check is uniquely numbered|
44
+
45
+
22
46
## sp_Develop Parameter Explanations
23
47
24
48
|Parameter|Details|
@@ -31,7 +55,7 @@ EXEC dbo.sp_Develop
31
55
|@SkipChecksSchema|The schema for the skip check table, when you pass in a value the SkipCheckTSQL column will be used|
32
56
|@SkipChecksTable|The table that stores the skip checks, when you pass in a value the SkipCheckTSQL column will be used|
33
57
|@OutputType|TABLE = table<br/>COUNT = row with number found<br/>MARKDOWN = bulleted list<br/>XML = table output as XML<br/>NONE = none|
34
-
|@Debug|Default 0. When 1, we print out messages of what we're doing in the messages tab of SSMS. When 2, we print out the dynamic SQL query of the check.|
58
+
|@Debug|Default 0. When 1, we print out messages of what we're doing in the messages tab of SQL Server Management Studio. When 2, we print out the dynamic SQL query of the check.|
35
59
|@Version|Output variable to check the version number.|
36
60
|@VersionDate|Output variable to check the version date.|
37
61
|@VersionCheckMode|Will set the version output variables and return without running the stored procedure.|
@@ -106,7 +130,7 @@ The 'Test Database' folder contains the RedGate SQL Source Control. Use this dat
106
130
**Quick Steps to Setup and Use:**
107
131
108
132
1. Create new database 'spDevelop' and select in Object Browser
109
-
2. Open RedGate SQL Source Control in SSMS
133
+
2. Open RedGate SQL Source Control in SQL Server Management Studio
110
134
3. Click 'Setup' tab
111
135
4. Select 'Link to my source control system' and click 'Next'
112
136
5. Browser to '..\Test Database' cloned folder and click 'Link'
@@ -115,7 +139,7 @@ The 'Test Database' folder contains the RedGate SQL Source Control. Use this dat
115
139
8. Develop objects to use when you create a new check
116
140
9. Click 'Commit' tab
117
141
10. Select objects to be pulled back into the branch, add comment, click the 'Commit' button and click the 'Push' button
118
-
11.**Note:** there are exclude fiters setup for invalid objects created in the post script. Do not check these objects back into the branch.
142
+
11.**Note:** there are exclude filters setup for invalid objects created in the post script. Do not check these objects back into the branch.
119
143
120
144
121
145
**RedGate SQL Source Control Documentation**
@@ -132,7 +156,7 @@ Included in this project are settings you can use for database development. Usin
132
156
The settings are located in the project "[\SQL-Server-Assess\Development Application Settings\Microsoft\SQL Server Management Studio\General Settings](https://github.com/EmergentSoftware/SQL-Server-Assess/tree/master/Development%20Application%20Settings/Microsoft/SQL%20Server%20Management%20Studio/General%20Settings)"
133
157
134
158
1. Cloned or forked the repo
135
-
2. In SSMS navigate to "Tools > Options > Environment > Import and Export Settings"
159
+
2. In SQL Server Management Studio navigate to "Tools > Options > Environment > Import and Export Settings"
136
160
3. Check "Use team settings file" and browse to "..\SQL-Server-Assess\Development Application Settings\Microsoft\SQL Server Management Studio\General Settings\SSMS.vssettings"
137
161
4. Click the "OK" button
138
162
@@ -263,9 +287,9 @@ Never use a descriptive prefix such as tbl_. This 'reverse-Hungarian' notation h
263
287
264
288
The use of the tbl_prefix for a table, often called "tibbling", came from databases imported from Access when SQL Server was first introduced. Unfortunately, this was an access convention inherited from Visual Basic, a loosely typed language.
265
289
266
-
SQL Server is a strongly typed language. There is never a doubt what type of object something is in SQL Server if you know its name, schema and database, because its type is there in sys.objects: Also it is obvious from the usage. Columns can be easily identified as such and character columns would have to be checked for length in the Object Browser anyway or Intellisense tooltip hover in SSMS.
290
+
SQL Server is a strongly typed language. There is never a doubt what type of object something is in SQL Server if you know its name, schema and database, because its type is there in sys.objects: Also it is obvious from the usage. Columns can be easily identified as such and character columns would have to be checked for length in the Object Browser anyway or Intellisense tool-tip hover in SQL Server Management Studio.
267
291
268
-
Do not prefix your columns with "fld_", "col_", "f_", "u_" as it should be obvious in SQL statements which items are columns (before or after the FROM clause). Do not use a data type prefix for the column either, for example, "IntCustomerId" for a numeric type or "VcName" for a varchar type.
292
+
Do not prefix your columns with "fld_", "col_", "f_", "u_" as it should be obvious in SQL statements which items are columns (before or after the FROM clause). Do not use a data type prefix for the column either, for example, "IntCustomerId" for a numeric type or "VcName" for a VARCHAR type.
269
293
270
294
271
295
@@ -507,7 +531,7 @@ T-SQL code must execute properly and performant. It must be readable, well laid
507
531
508
532
Your scalar function is not inlineable. This means it will perform poorly.
509
533
510
-
Review the [Inlineable scalar UDFs requirements](https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sql-server-ver15#inlineable-scalar-udfs-requirements) to determine what changes you can make so it can go inline. If you cannot, you should inline your scalar function in SQL query. This means duplicate the code you would put in the scalar function in your SQL code. SQL Server 2019 & Azure SQL Database (150 database compatibility level) can inline some scalar functions.
534
+
Review the [Inlineable scalar UDFs requirements](https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sql-server-ver15#inlineable-scalar-udfs-requirements) to determine what changes you can make so it can go inline. If you cannot, you should in-line your scalar function in SQL query. This means duplicate the code you would put in the scalar function in your SQL code. SQL Server 2019 & Azure SQL Database (150 database compatibility level) can inline some scalar functions.
511
535
512
536
Microsoft has been removing (instead of fixing) the inlineablity of scalar functions with every cumulative update. If your query requires scalar functions you should ensure they are being inlined. [Reference: Inlineable scalar UDFs requirements](https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sql-server-ver15#inlineable-scalar-udfs-requirements)
513
537
@@ -802,7 +826,7 @@ Views do not lend themselves to being deeply nested. Views that reference views
802
826
## Invalid Objects
803
827
**Check Id:**[NONE YET]
804
828
805
-
This check found objects that were deleted, renamed. Use can also run "Find Invalid Objects" with RedGate SQL Prompt in SSMS.
829
+
This check found objects that were deleted, renamed. Use can also run "Find Invalid Objects" with RedGate SQL Prompt in SQL Server Management Studio.
806
830
807
831
Try running EXEC sp_refreshsqlmodule or sp_refreshview.
0 commit comments