Datasheet

Edition interface. In addition, there is a free tool — Microsoft SQL Server Management Studio Express —
that mimics the more advanced administration tool that ships with the full version of SQL Server 2005. The
installation of this tool is shown in Appendix A. In this book you’ll use both of these techniques, and in most
cases you’ll be writing no more SQL code than is necessary.
It is perfectly possible to write SQL statements manually in your code, although it is often the case that
you don’t have to. Many .NET controls are capable of generating SQL commands automatically, which
certainly saves wear and tear on your fingers. Of course, this may not give you exactly the behavior you
require, and more advanced tasks will require custom SQL code, so it’s still worth learning how SQL
works. This book covers these controls, but you will also learn when and where you will need to write
SQL code yourself.
One subject that has become increasingly important in recent years is XML, which stands for eXtensible
Markup Language. This is a platform-independent standard for representing data in text files, and has
become extremely popular. It does have its disadvantages — it is a flat-file data format, after all — but
these are outweighed by what it makes possible. If you have had any experience using .NET, you’ve no
doubt encountered XML. The most recent DBMSes (including SQL Server 2005 Express Edition) include
additional capabilities to deal with XML data, both as a means of storage and as a format with which to
retrieve data — even if that data isn’t encoded as XML to start with. It is important that you cover the
basics of XML here because you are likely to need to know about it before too long.
The remainder of this section covers two topics:
A SQL Primer: The basics of the SQL language and what you can do with it.
XML: A brief overview of the XML language and further information on its relevance in the con-
text of databases.
A SQL Primer
This section is by no means a comprehensive guide to using SQL. In fact, entire books are devoted to the
subject, including one co-written by yours truly: The Programmers Guide to SQL (APress, 2003. ISBN:
1590592182). But it does teach you the basics.
There is a lot of code in this section, and you may find it useful to run these commands against a data-
base yourself to see what is happening. However, at this stage I don’t recommend doing so. You’ll get
plenty of experience doing this later in the book, and for now it is best just to get a basic understanding
of the SQL language and see what is possible. Later you may want to refer back to this section, so don’t
worry if you don’t take it all in the first time around.
Basic SQL Terminology and Syntax
Before getting into the SQL language itself, there are a few bits of basic terminology and syntax of which
you should be aware. First, a chunk of SQL code is known (interchangeably) as a statement, command, or
query. SQL statements might span several lines, and whitespace (spaces, tabs, new line characters, and so
forth) is ignored. SQL statements consist of keywords (such as
SELECT) and operators (+, -, and so on)
combined with literal values (string constants, numbers, and so on), table and column identifiers, and
often functions. SQL keywords are case-independent, but are typically written in uppercase to distin-
guish them from other parts of the statement. Common statements, such as those that retrieve data,
are often referred to by the first keyword in the statement, so you might hear people refer to a select
18
Chapter 1
44063c01.qxd:WroxBeg 9/12/06 10:31 PM Page 18