get rid of these 5 t-sql bad habits

Post on 13-Apr-2017

625 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

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

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

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

top related