×

Top 15 T-SQL(Transact-SQL) Interview Questions for 2024

1) What is T-SQL?

T-SQL stands for Transact Structured Query Language. T-SQL is the extension of SQL functionality supported by Microsoft SQL Server and Sybase ASE.

2) What are the features of T-SQL?

T-SQL makes enhancement in SQL server and provides the following features:
  • TRUNCATE TABLE with PARTATION.
  • DROP IF EXISTS.
  • Advanced Analytics Extensions.
  • Querying Temporal Tables
  • JSON support.
  • FORMATMESSAGE

3) What is difference between T-SQL and SQL?

  • T-SQL gives different implementation of DELETE and UPDATE than SQL.
  • T-SQL is best if it use Microsoft SQL servers.
  • T-SQL supports local variable, procedural programming but, SQL does not.
  • T-SQL is proprietary control under Microsoft while SQL is an open format.

4) What are the different data types in T-SQL?

T-SQL has different categories of data types:
Integer types (bigint, int, smallint, tinyint, bit,decimal,numeric,money,smallmoney).
Floating types (Float, Real).
Character Strings (char, varchar, Varchar(max), text)
Unicode Charcter Strings (nchar, nvarchar, Nvarchar(max), ntext)
Date and Time types (datetime, smalldatetime, date, datetimeoffset, datetime2, time).
Binary Strings (binary, varbinary, varbinary(max), image).
Others (sql_variant, timestamp, uniqueidentifier, xml, cursor, table, hierarchyid).

5) How can you execute a T-SQL query from command prompt?

  • OSQL
  • SQLCMD

6) What do you understand about Index in TSQL?

Index is special lookup used to retrieve data from database very fast. CREATE INDEX statement is used to create an index. Index is not visible to user. Creating and deleting of INDEX dose not effects on data. Syntax:
CREATE INDEX index_name ON table_name;

7) How local variable is defined in T-SQL?

Local variable is defined by using “DECLARE” statement and the name of local variable must start with "@" character in T-SQL. Syntax:
DECLARE @variable_name data_type;

8) What is "GO" in T-SQL?

GO is not a T-SQL statement, it signs the end of batch of T-SQL statement. It is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code Editor.

9) What is dynamic SQL statement?

A dynamic SQL statement is created at execution time. Dynamic SQL statement is useful when you need to decide at run time what field to be chosen with different criteria of queries. Syntax:
DECLARE @WhereClause NVARCHAR(2000)  
SET @WhereClause = ' Prouct = ''Computer'''  

SELECT * FROM SalesHistory WHERE @WhereClause
Example:
DECLARE @Product VARCHAR(20)  
SET @Product = 'Computer'   

SELECT * FROM SalesHistory WHERE Product = @Product

10) What is the difference between TRUNCATE and DELETE statement?

DELETE TRUNCATE
DELETE statement is used to remove data record with condition clause. TRUNCATE statement is used to remove all data records from table without any condition.
DELETE is slower. TRUNCATE is faster.
DELETE is DML statement. TRANCATE is DDL statement.

11) What is NULL and UNKNOWN in T-SQL?

NULL is a value which is unknown. A null value is different from zero or an empty value. The comparison between two null values returns unknown because the value of each null is unknown.

12) What is @@ERROR in T-SQL?

@@ERROR returns the error number of last T-SQL statement executed. 
It returns 0 if the last executed statement has no error.

13) What are the Join Types in TSQL?

TSQL has the following join types:
  • Inner join
  • Outer join
  • Left outer join
  • Right outer join
  • Left outer join with Exclusions
  • Right outer join with Exclusions
  • Full outer join
  • Full outer joins with Exclusions
  • Cross join

14) What is transaction Auto commit?

Auto commit is a default transaction management mode. Every statement is committed or rolled back when complete. When SQL statement successfully completed it is committed otherwise it is rolled back.

15) What is sub-query in TSQL?

Sub Query is a query that is nested inside another query. A sub query returns data which is further used in main query as a condition to generate final result. The sub query executed before the parent query. Syntax:
FROM   table1 [, table2 ]  
WHERE  column_name OPERATOR  
    (SELECT column_name [, column_name ]  
    FROM table1 [, table2 ]   [WHERE])

Related Topics

Top 25 CoffeeScript Interview Questions for 2024

1) What is CoffeeScript? It is a language that compiles into JavaScript. CoffeeScript is an attempt to expose good parts of JavaScript so, that user can code more easily. 2) Name the...

3 minutes read.

Top 30 WordPress Interview Questions for 2024

Most Frequently asked WordPress Interview Questions and Answers 2019 1) What is WordPress? WordPress is an open-source CMS (Content Management System) and a blogging tool. It is used to create web sites and...

5 minutes read.

Top 12 Docker Interview Questions for 2024

Most frequently asked Docker Interview Questions and Answers for Fresher 1. What is Docker? Docker is a new form of Software Containerization in the field of IT. It is an open-source container...

4 minutes read.

Top 30 Ruby on Rails Interview Questions for 2024

1) What is Ruby on Rails? It is a server-side web application framework. It is an open source ruby framework which is used for developing database-backed web applications. Here, no compilation phase is...

4 minutes read.

Top 30 Flex Interview Questions for 2024

1) What is Flex? Flex is an open source framework which is used to build applications for mobile, browser and desktop. It provides FLEX SDK consisting of the Flex class library, Flex...

4 minutes read.

Ember.js Interview questions

1) What is Ember.js? Ember.js is a JavaScript front-end Framework. It provides developer both features for managing complexity in modern web-apps as well as integrated development kit. 2) Why choose Ember.js? Logical...

2 minutes read.

Top 15 Bootstrap Interview Questions for 2024

1) Explain what is Bootstrap? It is a Framework which is used for building the web application with minimal effort. Bootstrap is also used for developing responsive, mobile-first web sites. 2) What...

10 minutes read.

Top 30 Magento Interview Questions for 2024

1) What is Magento? Magento is an open-source content management system. It is used to create e-commerce websites. It is developed by Varien ,Inc, a US private company headquartered in Culver City, California. It...

5 minutes read.

Top 14 Apache Presto Interview Questions for 2024

1) What is Presto? Presto is a distributed SQL query engine. It is an open source software project to develop a database. 2) What are the features of Presto? There are following features...

2 minutes read.

Top 31 Dart Programming Interview Questions for 2024

1) What is Dart? Dart is an application programming language. It is used to build web, server and mobile applications. 2) Who is the developer of Dart? Google is the developer of Dart. 3)...

6 minutes read.

Top 30 CodeIgniter interview Questions for 2024

1) What is CodeIgniter? CodeIgniter is an open source PHP framework. It is used to develop web applications and websites. It is loosely based on MVC pattern and easy to use...

4 minutes read.

Top 15 Data structure & Algorithm Interview Questions for 2024

1) What is Data Structure? Data structure is a way of storing, collecting and organizing data into the main memory. It makes data access more efficient and increase performance. Array, List, Queue...

3 minutes read.

Top 15 XHTML Interview Questions for 202

1) What is XHTML? XHTML (Extensible Hyper Text Markup Language) it is similar to the HTML but has some strict rule than HTML. It is said to be HTML defined as...

3 minutes read.

Top 15 Pure CSS Interview Questions for 2024

1) What is Pure CSS? Pure is a CSS (Cascading Style Sheet) framework. It is a collection of small set of responsive CSS modules. We can integrate it to any web...

5 minutes read.

Top 30 Core Java Interview Questions for 2024

1. What is the difference between HashMap and Hashtable in Java? Ans. S.No. HashMap Hashtable 1. ...

6 minutes read.

Top 48 C# Interview Questions for 2024

1) Write a program in C# to print "HELLO WORLD"? class Program         {          static void Main(string  args[])           {             System.Console.WriteLine(" HELLO WORLD ");             }          } 2) Write a program in C# to print "TutorialandExample" using namespace? Here, namespace is used to group related classes. Using System;    namespace  TutorialandExample      {         public class           {             public static void Main(string[]  args)             {              Console.WriteLine(" TutorialandExample ");             }          }       } 3) What are the...

8 minutes read.

Top 30 SQLite Interview Question for 2024

1) What is SQLite? It is an in-process library which implements self-contained, serverless, zero-configuration, transactional SQL database. 2) What datatype does SQLite supports? It uses dynamic typing and data can be stored in...

5 minutes read.

Top 15 Meteor Interview Questions for 2024

1) What is Meteor or MeteorJS? Meteor is a JavaScript platform used for developing web and mobile applications. Applications develop using Meteor framework supports different platforms (like windows, android, ios). Meteor...

4 minutes read.

Top 15 Servlet Interview Questions for 2024

1) What is Servlet? It is a technology used to create web applications. It is a web component which is used to create dynamic web pages. It consists of many interfaces and classess...

2 minutes read.

Top 29 Pascal Interview Questions for 2024

1) What is Pascal? Pascal is a high-level and Algol-based language that was developed by Niklaus Wirth. It is used to develop efficient and reliable programs. 2) What are the features of Pascal? Features...

4 minutes read.