When to use this tag:
Use this tag for SQL questions for sybase orsql-server.
Do not use this tag for questions about other database vendors, since T-SQL is only used by these two products.
How to write a good T-SQL question:
There are five 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 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 tsql, also provide the product tag (either sybase orsql-server), and 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
T-SQL (Transact Structured Query Language) is the extension of SQL functionality supported by Sybase ASE and Microsoft SQL Server. They share the name because Microsoft SQL Server was based on Sybase ASE code in a partnership that later dissolved. While the name is shared, functionality is not necessarily identical. With the introduction of Microsoft SQL Server 2005, the SQL Server code was completely re-written to provide integration with .Net.
Transact-SQL is central to using Microsoft SQL Server. All applications that communicate with an instance of SQL Server do so by sending Transact-SQL statements to the server, regardless of the user interface of the application.
It adheres to nearly all SQL standards, yet supplies an additional set of functionality not a part of the SQL standard, with concepts such as common table expressions, index hints, and the ability to SELECT scalars.
Questions about T-SQL should be tagged appropriately with eithersql-server or sybase, and include the version as well.