Transact-SQL

Transact-SQL (T-SQL) is an extension of SQL used by Microsoft SQL products and services, including Microsoft SQL Server, and by SAP Adaptive Server Enterprise (SAP ASE). Microsoft states that tools and applications communicating with a SQL Server database do so by sending T-SQL commands.[1] SAP describes its implementation as an enhanced version of the relational database language.[2]

History

In January 1988, Microsoft and Ashton-Tate announced Microsoft SQL Server, based on a relational database management system licensed from Sybase.[3] Sybase Adaptive Server Enterprise was later renamed SAP Adaptive Server Enterprise.[4] Microsoft and SAP publish separate Transact-SQL documentation for their respective database systems.[1][2]

Microsoft implementation

The features described in this section refer to Microsoft's implementation of Transact-SQL.

Variables and control flow

Local variables begin with an at sign (@) and are declared using DECLARE. A newly declared variable has the value NULL. Values can be assigned using SET or SELECT, although Microsoft recommends SET for variable assignment.[5]

Control-flow constructs include BEGIN...END, IF...ELSE, WHILE, BREAK, CONTINUE, RETURN, GOTO, WAITFOR, THROW, and TRY...CATCH.[6]

Stored procedures and error handling

Stored procedures can accept input parameters, return values through output parameters, contain statements that operate on a database, and return a status value to their caller.[7]

The TRY...CATCH construct transfers control to a CATCH block when certain execution errors occur inside its associated TRY block.[8]

Data modification and bulk loading

Transact-SQL extends the DELETE statement with an additional FROM clause, allowing rows to be identified using joined table sources.[9] Its UPDATE statement also accepts a FROM clause containing table, view, or derived-table sources used to determine which rows are updated.[10]

The BULK INSERT statement imports data from a file into a table or view. Depending on the Microsoft database product, the source can be a file accessible to the server or a file in Azure Storage.[11]

See also

References

  1. ^ a b "Transact-SQL Reference (Database Engine)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  2. ^ a b "Transact-SQL Users Guide". SAP Help Portal. SAP. Retrieved 31 July 2026.
  3. ^ "The History of Microsoft – 1988". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  4. ^ "What is Sybase?". SAP. SAP. Retrieved 31 July 2026.
  5. ^ "Variables (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  6. ^ "Control-of-Flow". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  7. ^ "CREATE PROCEDURE (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  8. ^ "TRY...CATCH (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  9. ^ "DELETE (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  10. ^ "UPDATE (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.
  11. ^ "BULK INSERT (Transact-SQL)". Microsoft Learn. Microsoft. Retrieved 31 July 2026.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.