WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

SQL Server · Basic · question 2 of 100

Can you explain the difference between SQL and T-SQL?

📕 Buy this interview preparation book: 100 SQL Server questions & answers — PDF + EPUB for $5

SQL (Structured Query Language) is a standard language used to communicate with relational database systems. SQL is used to create, read, update, and delete (CRUD) data in these databases. Various database vendors like Oracle, Microsoft, and MySQL support SQL language.

T-SQL (Transact-SQL) is a proprietary procedural language used by Microsoft SQL Server. T-SQL is an extension of SQL and provides additional programming constructs that are not available in standard SQL. T-SQL supports programming constructs like stored procedures, triggers, user-defined functions, and transactions.

Here are some of the differences between SQL and T-SQL:

1. Programming constructs: T-SQL supports procedural constructs like cursors, control statements, and exception handling, which are not supported in standard SQL. T-SQL also supports stored procedures, user-defined functions, and triggers.

2. Functionality: T-SQL provides additional functionality over SQL. For example, T-SQL includes the ability to handle errors, control program flow using loops, and conditionals, manipulate data using cursors, and work with variables.

3. Syntax differences: While T-SQL syntax is based on SQL, it contains additional statements and keywords. For example, T-SQL includes the "BEGIN" and "END" keywords to define blocks of code.

4. Database support: SQL is a standard language and can be used with various relational database systems. T-SQL, on the other hand, is mostly used with Microsoft SQL Server.

Here is a simple example of the T-SQL code for creating a stored procedure:

CREATE PROCEDURE GetCustomer
@CustomerId INT
AS
BEGIN
SELECT * FROM Customers WHERE CustomerId = @CustomerId
END

This code creates a stored procedure named "GetCustomer" that accepts a parameter "CustomerId". The procedure selects data from the "Customers" table where "CustomerId" matches the input parameter.

In summary, SQL is a standard language used with relational database systems, while T-SQL is a proprietary language used with Microsoft SQL Server. T-SQL includes additional programming constructs and functionality not found in SQL.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic SQL Server interview — then scores it.
📞 Practice SQL Server — free 15 min
📕 Buy this interview preparation book: 100 SQL Server questions & answers — PDF + EPUB for $5

All 100 SQL Server questions · All topics