SQL Server Interview Questions and Answer Part 5

30. What is the difference between varchar and nvarchar types?

Answer:

Varchar and nvarchar are same except with the difference of nvarhcar can be used to store Unicode characters for multiple languages and it also takes more space when compared with varchar.

31. Explain the difference between GETDATE and SYSDATETIME.

Answer:

SYSDATE TIME is more accurate than GETDATE

GETDATE can give time till milliseconds

SYSDATETIME can give precision till nanoseconds.

32. What is SQL injection?

Answer:

SQL injection is one of the most common web hacking techniques to destroy a database.

SQL injection is the placement of malicious code in a poorly-designed application and then passed to the backend database, via web page input.

33. What is a view in the database?

Answer:

A View is a named query that combines data from multiple tables using adequate joins.

Views are good for security purposes because they provide encapsulation of the name of the table. Data is in the virtual table, not stored permanently. Views display only selected data.

34. What is Normalization?

Answer:

Normalization is the processing of organizing data to minimize redundancy wherein the database is divided into tables and a relationship is defined among the tables.

35. What is De-Normalization?

Answer:

De-Normalization is the process of adding redundancy intentionally to optimize the performance of a database.

36. What is the difference between function and stored procedure?

Answer:

Function must return a value while stored procedure may or may not return values.

Functions can have input parameter while stored procedures can have both input and output parameters.

Functions must take one mandatory input parameter while stored procedures has no such compulsion

Functions don't support exception handling while exceptions can be handled by try-catch block in stored procedure.