Russ Thomas – SQL Judo

The Art of SQL Server Database Administration, Development, and Career Skills for the Technically Minded

Can you read the syntax of books online?

If you have any professional experience with SQL Server I guarantee at some point you have relied heavily on books online (Tech Net, MSDN).  The last Microsoft test I passed I mostly focused on the “skills measured” summary as a guide and books online as a resource.  Worked out fine.

Remember the bar scene from Goodwill Hunting when Matt Damon’s character Will is verbally sparring with the grad student who was trying to make him look stupid in front of Skylar.  Will finishes with: “so you dropped a hundred and fifty grand on an education you coulda’ got for a dolla’ fifty in late charges at the public library.”

Yeah, books online is kinda like that – with no late fees.

Most online resources have a format they use to define the bounds of the syntax. The image here, for example, is from sqlite.
alter

If you’re like me, I tend to skim this section when referencing books online.  In fact typically I just jump to the bottom and search through the examples for something close to what I’m trying to do.  The syntax Microsoft uses can be a lot to look at – for a long time I gave it no more than a cursory glance when tackling a new topic.

With that said, if you don’t at least know how to read the syntax formatting – you’re missing out on important foundational clues that can really help you understand the topic at hand, especially for those moments when no applicable example can be found and you need to craft your own from the blue-print provided.

Consider the SELECT documentation below taken directly from Microsoft SQL Server Books Online.  Look at all those brackets and braces and angles and commas and pipes and … well, just look at them.

<SELECT statement> ::=
[WITH <common_table_expression> [,…n]]
<query_expression>
[ ORDER BY { order_by_expression | column_position [ ASC | DESC ] }
[ ,…n ] ]
[ <FOR Clause>]
[ OPTION ( <query_hint> [ ,…n ] ) ]
<query_expression> ::=
{ <query_specification> | ( <query_expression> ) }
[  { UNION [ ALL ] | EXCEPT | INTERSECT }
<query_specification> | ( <query_expression> ) […n ] ]
<query_specification> ::=
SELECT [ ALL | DISTINCT ]
[TOP ( expression ) [PERCENT] [ WITH TIES ] ]
< select_list >
[ INTO new_table ]
[ FROM { <table_source> } [ ,…n ] ]
[ WHERE <search_condition> ]
[ <GROUP BY> ]
[ HAVING < search_condition > ]

Microsoft documents this syntax convention in books online. ( Were you expecting somewhere else? ).  The question is, have you ever taken the time to read through it and understand the formatting?

Do you know the difference between [….n] and [ ,…n ]? Do you know the difference between [ ] and ( ) and < >. Do you know that the | character means that you can specify any of the options included within { } – but only one of them?  Do you know why some things are all caps or the significance of ::= ?

Well, you should.

Take a glance at the link provided.  Spend a few minutes and get familiar with it if you never have before.  Once your  comfortable with it, you may find your curiosity peaked in new ways the next time you look up syntax and catch a nuance of the language you’ve never considered before.  It may surprise you to learn what options are mutually exclusive or which clauses are optional or mandatory.  When you know how to read the syntax this information jumps right out at you; no need to go digging.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on January 9, 2014 by in Career Skills, Fundamentals.
%d bloggers like this: