- Use [ ] brackets to specify coloumn name in select statement.
- Do not use SELECT * as it affects significant performance.
For. Eg.
SELECT * from Employees;
- Select query should have SELECT keyword in Capital Letters. For. Eg.
SELECT [ID] , [NAME] FROM Employees;
- Specify column name on seperate lines. For. Eg.
SELECT [ID] , [NAME] , [SALARY] FROM Employees;
- Comma seperator should be before the start of new column name. For. Eg.
SELECT [ID] , [NAME] , [SALARY] FROM Employees;
- Query should be optimize for better performance.
- Proper Indentation should be followed while writing the query.
- Define Aliases to change column name to your convenient name. Used to shorten Column Names of Coulmns having large names.
- 'AS' keyword is used to define aliases.
For. Eg.
SELECT [Department Name] AS [DeptName] FROM Employees;
- First Character of Identifier should start with (_), (@), #.
- Do not use Reserved keywords for identifiers.
- Not to use embedded special or supplementary characters.
- When keyword & column name are same use square bracket to use column name in query.
For. Eg.
SELECT [NAME] , [DATE] FROM Employees;
- Temporary Table can be created using #, ## or Table Variable.
- ';' should be specified at the termination of every statement.
- ';' always required for Common Table Expressions and Service Broker Commands.
- Code must contain comments.
- Remove unwanted code.
- Entity name should be plural.
- Primary key should be NOT NULL AND AUTO_INCREMENT.
- While inserting values in table
- Don't insert the value in auto incremented column.
- Inserting values should be in same case it means data should be consistant.
- While creating table obey all the rules of Normal Forms.
- Explicitly specify the order of column Like ASC or DESC.
- View name should start with 'V'. Ex. [vEmployee]
- Schema should be required for tables.
- All predefine clauses name sholud be in capital letters. Ex. FROM, SELECT etc.
http://www.sqlservertutorial.net/
https://www.javatpoint.com/sql-server-tutorial
https://www.tutorialspoint.com/ms_sql_server/index.htm
https://www.youtube.com/watch?v=ZNObiptSMSI&list=PL08903FB7ACA1C2FB
https://www.youtube.com/watch?v=eSUG8zZ7DfQ&list=PLVlQHNRLflP8WFEvFvANnUsD2y8HJIJh1