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
@@ -189,8 +197,10 @@ SQL Server T-SQL Coding Conventions, Best Practices, and Programming Guidelines.
189
197
- Avoid using asterisk in select statements `SELECT *`, use explicit column names.
190
198
More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-asterisk-select-list).
191
199
- No square brackets `[]` and [reserved words](https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Check_Reserved_Words_For_Object_Names.sql) in object names and alias, use only Latin symbols **`[A-z]`** and numeric **`[0-9]`**.
- All finished expressions should have semicolon `;` at the end. This is ANSI standard and Microsoft announced with the SQL Server 2008 release that semicolon statement terminators will become mandatory in a future version so statement terminators other than semicolons (whitespace) are currently deprecated. This deprecation announcement means that you should always use semicolon terminators in new development.
- All finished expressions should have semicolon `;` at the end.
202
+
This is ANSI standard and Microsoft announced with the SQL Server 2008 release that semicolon statement terminators will become mandatory in a future version so statement terminators other than semicolons (whitespace) are currently deprecated.
203
+
This deprecation announcement means that you should always use semicolon terminators in new development.
194
204
More details [here](http://www.dbdelta.com/always-use-semicolon-statement-terminators/).
195
205
- All script files should end with `GO` and line break.
196
206
- Keywords should be in **UPPERCASE**: `SELECT`, `FROM`, `GROUP BY` etc.
@@ -199,7 +209,8 @@ SQL Server T-SQL Coding Conventions, Best Practices, and Programming Guidelines.
199
209
- All system database and tables must be in **lowercase** for properly working for Case Sensitive instance: `master, sys.tables …`.
200
210
- Avoid non-standard column aliases, use, if required, double-quotes for special characters and always `AS` keyword before alias:
201
211
```sql
202
-
SELECTp.LastNameAS"Last Name"
212
+
SELECT
213
+
p.LastNameAS"Last Name"
203
214
FROMdbo.PersonAS p;
204
215
```
205
216
More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-avoid-non-standard-column-aliases).
@@ -487,7 +498,7 @@ More details [here](http://www.sqlservertutorial.net/sql-server-stored-procedure
487
498
/* Bad */
488
499
DECLARE @tsql nvarchar(max);
489
500
DECLARE @id int = 2107154552;
490
-
SET @tsql = N'SELECT object_id, "name" FROM master.sys.tables WHERE object_id = ' + CONVERT(nvarchar(max), @id);
501
+
SET @tsql = N'SELECT object_id, "name" FROM master.sys.tables WHERE object_id = ' + CAST(@id AS nvarchar(max));
491
502
EXEC sp_executesql @tsql;
492
503
493
504
/* Good */
@@ -567,3 +578,4 @@ More details [here](http://www.sqlservertutorial.net/sql-server-stored-procedure
0 commit comments