Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all Microsoft SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle, etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.
How to write a good SQL Server question
There are six ingredients to this recipe:
- Provide a clear textual explanation of the problem at hand.
- Provide proper sample data, as DDL (Create table statement(s)) and DML (Insert statement(s)). The sample data should be enough to demonstrate the problem, including edge cases. Usually, a few relevant rows are enough. (You can use SQLFiddle or db-fiddle as an online tool to generate DDL and DML statements for you from tabular data using their Text To DDL button.)
- Provide expected output for the sample data you've posted.
- Show your attempts to solve the problem.
- Tag properly. In addition to sql-server, also provide the tag for the lowest version you need the solution for. (I.e., if you're developing on SQL Server 2016, but the production server is SQL Server 2012, use sql-server-2012.)
- Do not include images of data or code!
A link to an online SQL test environment such as SQL Fiddle or DB Fiddle might help, but it is not a replacement for having all the data inside the question.
For more information, read Why should I provide an MCVE for what seems to me to be a very simple SQL query? and Help me write this query in SQL.
Questions about performance tuning should include, along with all of the above, the execution plan of the query. (How do I obtain a Query Execution Plan?). You can paste the execution plan on Brent Ozar's Paste The Plan and share a link to it in the question.
General Information:
Microsoft's SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality. It originated from the Sybase SQL Server 4.x codebase and Transact-SQL dialect (t-sql), but it has forked significantly since then.
SQL Server is available in multiple versions (typically identified by release year), each of which are subdivided into editions to distinguish between product functionality. The latest released version is SQL Server 2019 which was released on November 4th, 2019.
The SQL Server product range is split broadly into six categories:
SQL Server (sql-server) is the main suite of enterprise and developer server products. The primary differences are licensing costs, capacities, and components included in the product, with some minor differences supported language features. Standard components include database language and storage server, developer tools, ETL tools (ssis), schedulers, and replication. Other components include OLAP (ssas), reporting (reporting-services), and parallel computation. Components runs as NT Services.
SQL Server Express (sql-server-express) is free for use and distribution, but it has reduced engine performance, functionality and capacity than found in its other server siblings. It is focused on small deployments and runs as an NT service.
SQL Server Compact Edition (sql-server-ce) is an embeddable subset of SQL Server. Like the Express edition it has a reduced language, functionality and capacity, but it is free to distribute. It's focused on small installations and desktop applications where its small footprint and no-management-required features are a great advantage.
Note: SQL Server Compact Edition is deprecated. Customers should use SQL Server Express and possibly LocalDB).
Azure SQL Database (sql-azure) is a completely managed, hosted, high-availability product with similar features to SQL Server, operated in Microsoft Azure data centers. Notable differences are language syntax support for federated queries, and lack of support for CLR integration.
SQL Server Analytics Platform System (or APS), formerly known as SQL Server Parallel Data Warehouse (PDW), is a pre-built data warehouse appliance that offers massively parallel processing for SQL Server, allowing support for many hundreds of terabytes.
Azure SQL Data Warehouse is an enterprise-class distributed database in the Azure Cloud capable of processing up to petabyte volumes of relational and non-relational data. It is the industry's first cloud data warehouse with grow, shrink, and pause in seconds.
Microsoft offers a comparison table of the different SQL Server editions.
SQL Server Release History
+-------------+------+---------------------------+----------------------+
| Version | Year | Release Name | Codename |
+-------------+------+---------------------------+----------------------+
| 16.0 | 2022 | SQL Server 2022 | Dallas |
| 15.0 | 2019 | SQL Server 2019 | Seattle |
| 14.0 | 2017 | SQL Server 2017 | Helsinki |
| 13.0 | 2016 | SQL Server 2016 | SQL16 |
| 12.0 | 2014 | SQL Server 2014 | Hekaton |
| 11.0 | 2012 | SQL Server 2012 | Denali |
| 10.5 | 2010 | SQL Server 2008 R2 | Kilimanjaro (aka KJ) |
| 10.25 | 2010 | SQL Azure DB | CloudDatabase |
| 10.0 | 2008 | SQL Server 2008 | Katmai |
| 9.0 | 2005 | SQL Server 2005 | Yukon |
| 8.0 | 2003 | SQL Server 2000 x64 | Liberty |
| 8.0 | 2000 | SQL Server 2000 | Shiloh |
| - | 1999 | SQL Server 7.0 OLAP Tools | Palato mania |
| 7.0 | 1998 | SQL Server 7.0 | Sphinx |
| 6.5 | 1996 | SQL Server 6.5 | Hydra |
| 6.0 | 1995 | SQL Server 6.0 | SQL95 |
| 4.21(WinNT) | 1993 | SQL Server 4.21 | SQLNT |
| 1.1 (OS/2) | 1991 | SQL Server 1.1 | - (16-bit) |
| 1.0 (OS/2) | 1989 | SQL Server 1.0 | Ashton-Tate (16-bit) |
+-------------+------+---------------------------+----------------------+
References
- Microsoft Docs SQL Server 2022 Transact-SQL Reference
- Microsoft Docs SQL Server 2019 Transact-SQL Reference
- Microsoft Docs SQL Server 2017 Transact-SQL Reference
- Microsoft Docs SQL Server 2016 Transact-SQL Reference
- Microsoft Docs SQL Server 2014 Transact-SQL Reference
- Microsoft Docs SQL Server 2012 Transact-SQL Reference
- Microsoft Docs SQL Server 2008 R2 Transact-SQL Reference
- Microsoft Docs SQL Server 2008 Transact-SQL Reference
- Microsoft Docs SQL Server 2005 Transact-SQL Reference
- SQL Server Wikipedia Article
- SQL Azure Stack-Overflow Tag
- Microsoft SQL documentation
Tagging Recommendation
There are several version- and edition-specific tags. It is recommended to use the sql-server tag together with the version- and/or edition-specific tag; for example, sql-server-2005 or sql-server-2014-express. Do not use this tag for other types of DBMS (mysql, postgresql, oracle, etc.).