Skip Navigation Links
SQL Server 2012
SQL Server 2014
SQL Server 2016
Practice Test
Tip of the Day : SQL Server 2012 Management Studio Keyboard Shortcuts - Cut and Paste
SQL Server Error Messages
SQL Server 2008
SQL Server 2008 introduces the Compound Operators which execute some operation, such as + (addition), - (subtraction), * (multiplication) and / (division), and set an original value to the result of the operation.
One of the new programmability enhancements in the Database Engine introduced in SQL Server 2008 for Transact-SQL is the row constructor which consists of a single VALUES clause with multiple value lists enclosed in parentheses and separated by a comma.  With the row constructor, you can now insert multiple values using a single INSERT statement.
In this article, we will show how to use the row constructor (also called as table-valued constructor) as a derived table which you can use in the FROM clause of a SELECT statement and as a source table in a MERGE statement, yet another new statement introduced in SQL Server 2008.
One of the common tasks in database management is the maintenance of lookup tables.  Maintenance of these look-up tables are usually done using stored procedures where the normal task is to add the new record if it does not exist or update the existing record if it already exists based on the identified primary key of the table.  SQL Server 2008 introduces a new statement called MERGE statement which combines these functionalities into just a single statement.  The MERGE statement performs an INSERT, UPDATE or DELETE operation on a target table based on the results of a join with source table.
SQL Server 2008 introduces a new parameter type called the table-valued parameters.  With the table-valued parameters, which are declared by using user-defined table types, you can now send multiple rows of data to a function or stored procedure without creating a temporary table or many parameters.
When importing or exporting a table with a geometry or geography column, you might encounter an "unknown column type conversion" error.  This article shows how to manually resolve the issue.
This article discusses the two ways (automatic and manual) of opening the firewall port for SQL Server on Windows Server 2008 to solve the issue of "Could not open a connection to SQL Server (Microsoft SQL Server, Error: 1326)".
Most, if not all, retail store websites and bank websites have a way of helping their customers locate any of their retail store locations or bank branches given either a ZIP code or a full address.  Using the new Geography data type, SQL Server 2008 makes it easy to generate a list of store locations or bank branches given an address.
Prior to SQL Server 2008, geography locations are usually stored as latitude and longitude coordinates in two separate columns.  With the introduction of spatial data types in SQL Server 2008, particularly the GEOGRAPHY data type, this can now be stored as points in a single column stored as a spatial data object.
This article continues the discussion of the Table-Valued Parameters article and will combine this new feature with the MERGE statement, yet another new feature of SQL Server 2008.
This article shows the different connection strings that you can use when connecting to SQL Server 2008 using .NET Framework Data Provider for SQL Server, the SqlConnection class.
Importing data from a Microsoft Excel file prior to MS Excel 2007 was a straightforward task by simply selecting Microsoft Excel as the Data Source from the SQL Server Import and Export Wizard.  With Microsoft Excel 2007 files, selecting Microsoft Excel as the Data Source will not work because this Data Source is only for Microsoft Excel 97-2005.  This article walks you through the process of importing a Microsoft Excel 2007 file into a SQL Server 2008 database.
One of the most frequently asked questions in SQL Server forums is how to format a datetime value or column into a specific date format.  Here's a summary of the different date formats that come standard in SQL Server as part of the CONVERT function.  Following the standard date formats are some extended date formats that are often asked by SQL Server developers.
SQL Server 2005
This article compares the maximum sizes and numbers of various objects defined in SQL Server 7.0, SQL Server 2000 and SQL Server 2005 databases or referenced in Transact-SQL statements.
This article compares, in a tabular format, all available configuraion options for both SQL Server 2000 and SQL Server 2005, showing the range of possible settings and default values.
Accelerate Business Insight with SQL Server 2005 for Data Warehousing.
Tips and Tricks
Return a comma-separated value without the use of cursors.
Easily identify missing identity values in your table.
An alternative to SQL Server's RAND mathematical function.
Generate a certain number of random records from any of your tables.
Sort IP addresses that are stored as VARCHAR by their numeric values.
Different ways of splitting a full name to get the first name and last name.
Query/read and import an Excel file without using DTS and without loading the data to a SQL table.
Execute a batch of .sql scripts located in a specific directory without having to manually open each .sql script and executing them in Query Analyzer.
Provides a list on how to convert datetime values into different date formats.
Shows the differences between using the SET command and the SELECT statement when assigning a value to a local variable.
String Functions
Returns the number of times a given input character exists in a given input string.
Returns the number of times a given search string exists in a given input string.
Returns the number of words in a given input string.
Emulates the behavior of Oracle's InitCap string function, which changes the first letter of each word in uppercase and all others in lowercase.
A string encryption and decryption function that uses a simple algorithm to encrypt and decrypt string values.
Trims the leading zeros of an alphanumeric value.
Date Functions
Computes for the age given the birth date and the reference date.
Determines whether the input date is a leap year or not.
Returns the first day of the week for a given date.
Returns the first day of the month for a given date.
Returns the first day of the quarter for a given date.
Returns the last day of the month for a given date.
Returns the input date removing the time portion.
Returns the number of days in a month.
Returns the number of days in a year.
Tree Functions
Returns the path of a node from the parent to the current node in a hierarchical/tree-type table.
Returns the level of a given node in a hierarchical/tree-type table.
Table-Valued Functions
Returns a table containing integer values from 1 to a maximum value.
Returns a table containing the comma-delimited value parameter as separate records.
SQL Server Built-in Functions
SQL Server aggregate functions perform a calculation on a set of values and return a single value.  With the exception of the COUNT aggregate function, all other aggregate functions ignore NULL values.  Aggregate functions are frequently used with the GROUP BY clause of the SELECT statement.
SQL Server configuration functions return information about the current configuration option settings.
SQL Server date and time functions are scalar functions that perform an operation on a date and time input value and returns either a string, numeric, or date and time value.
SQL Server scalar math functions perform a calculation, usually based on input values that are provided as arguments, and return a numeric value.
SQL Server metadata functions return information about the database and database objects.
SQL Server security functions return information about users and roles.  Security functions return information that is useful in managing security.
SQL Server string functions are scalar functions that perform an operation on a string input value and return a string or numeric value.
SQL Server system functions perform operations on and return information about values, objects, and settings in SQL Server.