Skip to content

Commit 8e6b218

Browse files
Merge pull request #108 from EmergentSoftware/dev
fixed documentation
2 parents fab8d6c + 83dff67 commit 8e6b218

File tree

4 files changed

+72
-76
lines changed

4 files changed

+72
-76
lines changed

Development Application Settings/Microsoft/SQL Server Management Studio/General Settings/SSMS.vssettings

Lines changed: 1 addition & 18 deletions
Large diffs are not rendered by default.

Images/sp_Develop_Results.png

29.6 KB
Loading

README.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,61 @@
11
# SQL Server Assess Overview
22
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.
33

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).
55

66
## sp_Develop Install Instructions
77

88
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.
99

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.
1111

1212
## sp_Develop Usage Instructions
1313

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.
1515

1616
```sql
1717
EXEC dbo.sp_Develop
1818
```
1919

2020
[Check out the parameter section for more options](#Parameter-Explanations)
2121

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.
25+
26+
![sp_Develop Results](Images/sp_Develop_Results.png)
27+
28+
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+
2246
## sp_Develop Parameter Explanations
2347

2448
|Parameter|Details|
2549
|--|--|
2650
|@DatabaseName|Defaults to current DB if not specified|
2751
|@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.|
2853
|@SkipChecksServer|The linked server name that stores the skip checks|
2954
|@SkipChecksDatabase|The database that stores the skip checks|
3055
|@SkipChecksSchema|The schema for the skip check table, when you pass in a value the SkipCheckTSQL column will be used|
3156
|@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.|
3357
|@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.|
3659
|@Version|Output variable to check the version number.|
3760
|@VersionDate|Output variable to check the version date.|
3861
|@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
107130
**Quick Steps to Setup and Use:**
108131

109132
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
111134
3. Click 'Setup' tab
112135
4. Select 'Link to my source control system' and click 'Next'
113136
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
116139
8. Develop objects to use when you create a new check
117140
9. Click 'Commit' tab
118141
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.
120143

121144

122145
**RedGate SQL Source Control Documentation**
@@ -133,7 +156,7 @@ Included in this project are settings you can use for database development. Usin
133156
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)"
134157

135158
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"
137160
3. Check "Use team settings file" and browse to "..\SQL-Server-Assess\Development Application Settings\Microsoft\SQL Server Management Studio\General Settings\SSMS.vssettings"
138161
4. Click the "OK" button
139162

@@ -253,7 +276,7 @@ FROM
253276

254277
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.
255278

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.
257280

258281

259282

@@ -264,9 +287,9 @@ Never use a descriptive prefix such as tbl_. This 'reverse-Hungarian' notation h
264287

265288
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.
266289

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.
268291

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.
270293

271294

272295

@@ -508,7 +531,7 @@ T-SQL code must execute properly and performant. It must be readable, well laid
508531

509532
Your scalar function is not inlineable. This means it will perform poorly.
510533

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.
512535

513536
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)
514537

@@ -803,7 +826,7 @@ Views do not lend themselves to being deeply nested. Views that reference views
803826
## Invalid Objects
804827
**Check Id:** [NONE YET]
805828

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.
807830

808831
Try running EXEC sp_refreshsqlmodule or sp_refreshview.
809832

0 commit comments

Comments
 (0)