SQL Interview Questions & Answer – Best TOP 10 (Day – 5)

SQL/RDBMS is one of the most widely used databases to date, and therefore SQL skills are important in most work roles.
In this SQL interview questions article, I will share with you some of the most frequently asked questions on SQL (Structured Query Language). This article is the perfect guide for you to learn all concepts related to SQL, Oracle, MS SQL Server, and MySQL databases. In this topic, all the examples are related to SQL Server.
I am keeping 10 questions and answers in each part, So Please read all 10 parts of this SQL Interview Questions article and get ready to crack the SQL interview for beginners or experience level.

How can you describe table structure in SQL server?SQL Interview Questions

sp_help tablename

The above query is used for the check table structure in SQL Server.
Ex:-
sp_help Tbl_Emp

How can you see the text of the stored procedure in the SQL server?

sp_helptext storedprocedurename

The above query is used to see the text of the stored procedure in the SQL server.
Ex:-
sp_helptext sp_EmpDetails

SQL Interview Questions & Answer – Best TOP 10 (Day – 4)

How can you encrypt the text of the stored procedure in SQL server?

WITH ENCRYPTION is used to encrypting the text of stored procedure in SQL server.
Please follow the below stored procedure.

CREATE PROCEDURE SP_EMP
@ID INT
WITH ENCRYPTION
AS
BEGIN
SELECT * FROM TBLEMP
WHERE ID =@ID
END

Is It possible to view the text of encrypted stored procedure in SQL server?

No, It is not possible to view the text of encrypted stored procedure in SQL server.
sp_helptext is not able to view the text of the encrypted stored procedure.

SQL Interview Questions & Answer – Best TOP 10 (Day – 3)

Write a dynamic SQL In a Stored Procedure?

EXECUTE() is used for executing dynamic queries in SQL servers.
Please follow the below stored procedure.

CREATE PROCEDURE SP_EMP
@ID VARCHAR(20)
AS
BEGIN
DECLARE @QUERY AS NVARCHAR(MAX)
SET @QUERY = 'SELECT * FROM TBLEMP WHERE ID ='+@ID
EXECUTE(@QUERY)
END

What is a trigger and How many types of triggers are in SQL Server?

A trigger is a stored procedure in a database that automatically invokes whenever a special event in the database occurs. For example, a trigger can be invoked when a row is inserted into a specified table or when certain table columns are being updated.

There are mainly two types.
After
Instead of

SQL Interview Questions & Answer – Best TOP 10 (Day – 2)

What is the difference between Truncate and Delete?

Truncate:

  • The truncate command is used to delete all the rows from the table.
  • It will free the space containing the table.
  • We can’t able to find a description of the table.

Delete:

  • Delete command is used to delete rows from a table.
  • It can’t free the space containing the table.
  • We can able to find a description of the table.

What is a table scan?

If you are not using an index on the table then the search query will search on every data.
This type of searching is called a Table scan.

SQL Interview Questions & Answer – Best TOP 10 (Day – 1)

What are the disadvantages of an Index?

please find the below disadvantages

  • Increased Disk Space
  • DML statements could be slow

What are the System Databases in SQL server?

There 4 databases are created automatically.

  • Master
  • Model
  • Msdb
  • Tempdb

Leave a Comment

Your email address will not be published. Required fields are marked *