get rid of these 5 t-sql bad habits

6
Get Rid of These 5 T-SQL Bad Habits

Upload: samvanga

Post on 13-Apr-2017

625 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Get rid of these 5 t-sql bad habits

Get Rid of These 5 T-SQL Bad Habits

Page 2: Get rid of these 5 t-sql bad habits

5. Using meaningless table aliases• Using abbreviations like (a, b, c,

etc.,) is hard to understand; you always have to scroll up or down to see what table or view the alias “h” refers to• You can let SQL Prompt always

specify alias by highlighting “Assign aliases” in the Options page• There’re several options for

customizing: tinyurl.com/tblalias

Page 3: Get rid of these 5 t-sql bad habits

4. Using Select *• Changes in the underlying

schema can cause unexpected results or even break applications• You can replace asterisk (*) with

a list of columns by clicking “Expand Wildcards” in the SQL Prompt menu or by typing Ctrl+B, Ctrl+W

Page 4: Get rid of these 5 t-sql bad habits

3. Using unqualified column names• If you don’t qualify column

names in a multi table select statement, it causes confusion• You’ve to wonder which table or

view a column is coming from• To avoid this, select “Qualify

Object Names” in the SQL Prompt menu or use Ctrl+B, Ctrl+Q on your keyboard

Page 5: Get rid of these 5 t-sql bad habits

2. Poorly formatting queries• It’ll be easy for you and others to

read your code if it’s properly formatted• You can format/intend using SQL

Prompt by choosing “Format SQL” in the menu or entering Ctrl+k,Ctrl+Y

Page 6: Get rid of these 5 t-sql bad habits

1. Leaving unused variables and parameters• Leaving unused variables and

parameters is misleading and confusing• To identify them, select “Find

Unused Variables and Parameters” in the SQL Prompt menu or type Ctrl+B, Ctrl+F