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
+37-14Lines changed: 37 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,61 @@
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|
25
49
|--|--|
26
50
|@DatabaseName|Defaults to current DB if not specified|
27
51
|@GetAllDatabases|Runs checks across all of the databases on the server instead of just your current database context. Does not work on Azure SQL Server.|
52
+
|@BringThePain|If you’ve got more than 50 databases on the server, this only works if you also pass in @BringThePain = 1, because it’s gonna be slow.|
28
53
|@SkipChecksServer|The linked server name that stores the skip checks|
29
54
|@SkipChecksDatabase|The database that stores the skip checks|
30
55
|@SkipChecksSchema|The schema for the skip check table, when you pass in a value the SkipCheckTSQL column will be used|
31
56
|@SkipChecksTable|The table that stores the skip checks, when you pass in a value the SkipCheckTSQL column will be used|
32
-
|@BringThePain|If you’ve got more than 50 databases on the server, this only works if you also pass in @BringThePain = 1, because it’s gonna be slow.|
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
-
|@OutputXMLasNVARCHAR|Set to 1 if you like your XML out as NVARCHAR.|
35
-
|@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.|
36
59
|@Version|Output variable to check the version number.|
37
60
|@VersionDate|Output variable to check the version date.|
38
61
|@VersionCheckMode|Will set the version output variables and return without running the stored procedure.|
@@ -107,7 +130,7 @@ The 'Test Database' folder contains the RedGate SQL Source Control. Use this dat
107
130
**Quick Steps to Setup and Use:**
108
131
109
132
1. Create new database 'spDevelop' and select in Object Browser
110
-
2. Open RedGate SQL Source Control in SSMS
133
+
2. Open RedGate SQL Source Control in SQL Server Management Studio
111
134
3. Click 'Setup' tab
112
135
4. Select 'Link to my source control system' and click 'Next'
113
136
5. Browser to '..\Test Database' cloned folder and click 'Link'
@@ -116,7 +139,7 @@ The 'Test Database' folder contains the RedGate SQL Source Control. Use this dat
116
139
8. Develop objects to use when you create a new check
117
140
9. Click 'Commit' tab
118
141
10. Select objects to be pulled back into the branch, add comment, click the 'Commit' button and click the 'Push' button
119
-
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.
120
143
121
144
122
145
**RedGate SQL Source Control Documentation**
@@ -133,7 +156,7 @@ Included in this project are settings you can use for database development. Usin
133
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)"
134
157
135
158
1. Cloned or forked the repo
136
-
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"
137
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"
138
161
4. Click the "OK" button
139
162
@@ -253,7 +276,7 @@ FROM
253
276
254
277
Table and view names should be singular, for example, "Customer" instead of "Customers". This rule is applicable because tables are patterns for storing an entity as a record – they are analogous to Classes serving up class instances. And if for no other reason than readability, you avoid errors due to the pluralization of English nouns in the process of database development. For instance, activity becomes activities, ox becomes oxen, person becomes people or persons, alumnus becomes alumni, while data remains data.
255
278
256
-
If writing code for n data integration and the source is plural keep the staging/integration tables the same as the source so there is no confusion.
279
+
If writing code for a data integration and the source is plural keep the staging/integration tables the same as the source so there is no confusion.
257
280
258
281
259
282
@@ -264,9 +287,9 @@ Never use a descriptive prefix such as tbl_. This 'reverse-Hungarian' notation h
264
287
265
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.
266
289
267
-
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.
268
291
269
-
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.
270
293
271
294
272
295
@@ -508,7 +531,7 @@ T-SQL code must execute properly and performant. It must be readable, well laid
508
531
509
532
Your scalar function is not inlineable. This means it will perform poorly.
510
533
511
-
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.
512
535
513
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)
514
537
@@ -803,7 +826,7 @@ Views do not lend themselves to being deeply nested. Views that reference views
803
826
## Invalid Objects
804
827
**Check Id:**[NONE YET]
805
828
806
-
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.
807
830
808
831
Try running EXEC sp_refreshsqlmodule or sp_refreshview.
0 commit comments