Introduction to TSQL Interview Questions And Answers
If you are looking for a job that is related to TSQL, you need to prepare for the 2019 TSQL Interview Questions. Though every interview is different and the scope of a job is also different, we can help you out with the top TSQL Interview Questions and answers, which will help you take the leap and get you success in your TSQL Interview.
Below is the list of Important 2019 TSQL Interview Questions that are asked mostly in an interview
1.Explain what is T-SQL?
2.Explain what are the differences between SQL and T-SQL?
The difference between T-SQL and SQL is that SQL is a query language to operate on sets, while TSQL is a proprietary procedural language used by MS SQL Server. Also, T-SQL has a different implementation of DELETE and UPDATE than SQL.
3.Please name at least five commands which can manipulate text in the T-SQL code. For example, replace a text string, obtain a portion of the text, etc.
•LEFT(character_expression, integer_expression ) – It returns left part of a character expression with the specified number of characters.
•CHARINDEX( findTextData, textData, [startingPosition] ) – It returns starting position of an expression in a character string, and starting position is optional.
•REPLACE( textData, findTextData, replaceWithTextData ) – It replaces a new value for occurrences of text found in the string.
•REVERSE( character_expression ) – It returns reverse of a character expression.
•LEN( textData ) – It returns the length of the string, excluding trailing blanks.
•LOWER ( character_expression ) – After converting an uppercase character to lowercase it will return a character expression.
•LTRIM( textData) – Leading blanks will be removed.
•PATINDEX( findTextData, textData ) – It returns the starting position integer value of text found in the string.
•REPLICATE(character_expression, integer_expression ) – It repeats a character expression for a specified number of times.
•RTRIM( textData) – Removes trailing blanks. SPACE( number of spaces ) – It repeats space value specified number of times.
•STUFF( textData, start, length, insert text data ) – It deletes a specified length of characters and inserts another set of characters at a specified starting point.
•SUBSTRING( textData, startPosition, length ) – It returns portion of the string.
•UPPER( character_expression ) – It returns a character expression with lowercase character to uppercase.
4.Is it possible to import data directly from T-SQL commands without using SQL Server Integration Services? If so, what are the commands?
Yes – There are Six commands available to import data directly into the T-SQL language. These commands include:
4.5 (1,561 ratings)
5.Mention what is ‘GO’ in T-SQL?
‘GO’ is not a Transact-SQL statement but a batch separator. It is a command identified by the sqlcmd and osql utilities and SQL Server Management Studio Code editor. SQL Server utilities read “GO” as a signal that they should send the current batch of TSQL statements to an instance of SQL Server.
6.Mention difference between DELETE statement and TRUNCATE statement?
With the use of DELETE and TRUNCATE command, all data will be lost in a table. The difference between DELETE statement and TRUNCATE statement is that,
•DELETE is used for conditional removal of data records from Tables. These operations are logged.
•TRUNCATE is used for unconditional removal of data records from Tables. Truncate Operations are not logged.
7.When to use COALESCE() & ISNULL() Functions?
The NULLability of result expression is different for ISNULL and COALESCE. The ISNULL return value is always considered NOT NULLable (assuming the return value is a non-nullable one) whereas COALESCE is not. So the expressions ISNULL(NULL, 1) and COALESCE(NULL, 1) although equivalent has different NULLability values. This makes a difference if you are using these expressions in computed columns and creating key constraints or making return value of a scalar UDF deterministic so that it can be indexed.
8.Mention what is sub-query?
A sub-query is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. A sub-query can be used with the statements like Update, select, delete and insert with the operators like =, >, <, >=,<=, etc
9.What are types of XML indexes in SQL Server?
Microsoft SQL Server supports different types of XML indexes. An XML index is different than a relational index. There are basically TWO types of XML Indexes viz., Primary XML Indexes and Secondary XML indexes. The Primary XML index is a clustered index on an internal table known as the node table that users cannot use directly from their T-SQL statements. To enhance search performance, we create secondary XML indexes. These create secondary links (RID) at leaf level for existing clustered index based KEY pages. A primary XML index should be created prior to creating the Secondary XML Indexes.
10.What is SQL Server?
SQL Server is a vast, easy, powerful Relational Database Management (also Data warehouse Management) application from Microsoft. It offers Database Development, Database Management, and Business Intelligence capabilities. This wonderful technology is very easy to master and manage. This offers following advantages:
•Easy To Use
•Support for Small, Medium and Large Database Storage
•Cheaper, compared to other RDBMS
•Data warehouse Support
•Enhanced Security Features
•Enterprise Feature Support
•Business Intelligence Support
•Highly Scalable and Powerful
•Low Cost of Ownership
11.Mention new error handling commands which are introduced with the SQL Server 2005 and beyond? What commands did they replace? How are they command used?
The new commands introduce with SQL Server 2005 are TRY and CATCH. Though they do not replace directly any specific command, but in many aspects TRY and CATCH can be used instead of RAISERROR. The TRY block covers business logic whereas the CATCH logic is for capturing the error.
12.Mention what is TOP in TSQL?
TOP limits the rows returned in a query result set to a specified number of rows or percentage of rows in SQL Server. When TOP is used in combination with the ORDER BY clause, the result set is limited to the first N number of ordered rows. Otherwise, it retrieves the first N number of rows in an undefined order.
This has been a guide to List Of TSQL Interview Questions and answers so that the candidate can crackdown these TSQL Interview Questions easily. This is most useful an valuable post on TSQL Interview Questions and answers.You may also look at the following articles to learn more –