Tech Point Fundamentals

Tuesday, July 13, 2021

SQL Table Variable Interview Questions

SQL Table Variable (TV) Interview Questions and Answers


Microsoft introduced table variables with SQL Server 2000 as an alternative to using temporary tables. The table variable is a special type of the local variable that helps to store data temporarily, similar to the temp table in SQL Server. 

Below are the most common interview questions based on the SQL Table Variable (TV):

Q01. What is Table Variable in SQL? 

Q02. In which version of SQL the Table Variable was introduced?

Q03. Can you create a Table variable schema by using the SELECT INTO command?

Q04. Can you use the User Defined Type in the Table Variable?

Q05. Can you assign a table variable to other table variables in SQL?

Q06. What is the storage location of a table variable?

Q07. Can you access the Table Variable before declaring it?

Q08. What is the scope of the Table Variable in SQL? 

Q09. Can you use a Table Variable in Dynamic Query?

Q10. Can you ALTER the Table Variable? 

Q11. Can you create an Index and constraints in Table Variable?

Q12. Can you add Foreign Key Constraints in Table Variable?

Q13. Can you Create an IDENTITY Column in Table Variable? Can you insert IDENTITY Values in the Table variable explicitly?

Q14. Can you create Clustered Index on Table Variables?

Q15. Can you use DML commands (INSERT, UPDATE, DELETE) on the Table Variable in SQL? Does it affect the underlying base table?

Q16. Does Table Variable create Magic Tables(INSERTED and DELETED)?

Q17. Can you TRUNCATE the Table Variable in SQL?

Q18. How can you reset the Identity Column in Table Variable?

Q19. Can you Drop the Table Variable?

Q20. Can you JOIN a Table Variable with any other Table Variable, Temp Table or Normal Table? Can you join without any alias name?

Q21. Can you use the Explicit Transaction Statement on Table Variable?

Q22. Does the Table variable hold locks?

Q23. Does the transaction log created for the operation performed on the Table Variable?

Q24. Does MS SQL use the cached plans for the Table Variable?

Q25. Does MS SQL maintain statistics for the Table Variable?

Q26. Can you use Table Variable in User-Defined Function?

Q27. Can you use the table variable as an input or output parameter for function or stored procedure?

Q28. Can you create a Trigger on the Table Variable?

Q29. Can a table variable defined in a stored procedure be used in the nested stored procedure?

Q30. Which collation will be used in the case of Table Variable, the database on which it is execution or temp DB? What is a collation conflict error and how you can resolve it?

Q31. What is the difference between Table Variable and Temp Table?

Q32. What is the difference between Table Variable and Derived Table in SQL?

Q33. What is the difference between Table Variable and Common Table Expression in SQL?

Live Demo

Watch our related videos here

Recommended Articles

Derived Table (DT) Interview Questions
Common Table Expression(CTE) Interview Questions
Temp Table Interview Questions
Partial Interface Methods in C# 8
Interface Member Modifiers in C# 8
Multiple Interface Inheritance in C# 8
Interface Virtual Method in C# 8
Interface Access Modifiers in C# 8

Thanks for visiting this page. Please follow us on Twitter, Facebook, LinkedIn, Telegram, WhatsApp, Youtube, and Pinterest for regular updates.

No comments:

Post a Comment

Please do not enter any HTML. JavaScript or spam link in the comment box.