How to determine which version of SQL Server 2005 is running
To determine which version of Microsoft SQL Server 2005 is running, connect to SQL Server 2005 by using SQL Server Management Studio, and then run the following Transact-SQL statement:
(New Query in the upper left)
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
SELECT column FROM table
WHERE column operator value ('value' for strings or chars, no ' ' for numbers)
= Equal
<> Not equal (sometimes != )
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN If you know the exact value you want to return for at least one of the columns
SELECT * FROM Persons WHERE FirstName LIKE 'O%' (Note that the % acts like a * wildcard operator)
Some SQL tutorials end each SQL statement with a semicolon. Is this necessary?
We are using MS Access and SQL Server 2000 and we do not have to put a semicolon after each SQL statement, but some database programs force you to use it.
The DISTINCT keyword is used to return only distinct (different) values. (unique even if it would have returned many copies)
The ORDER BY clause is optional. If used, it must be the last clause
ORDER BY column-1 [ASC|DESC] [ column-2 [ASC|DESC] ] (column-1 can be a column name, preferred, or column number from the table)
ORDER BY sorts rows using the ordering columns in left-to-right, major-to-minor orde A null column sorts higher than all regular values; this is reversed for DESC.
e.g. SELECT name , (population / 1E6) FROM bbc WHERE region = 'Asia' ORDER BY 2 DESC
SELECT name , (GDP / population) , GDP FROM bbc WHERE (population >= 2E8) ORDER BY (GDP / population) DESC
sources: