SQL Server Interview Question and Answers

71. What is the difference between SET and SELECT?
  Both SET and SELECT can be used to assign values to variables. It is recommended that SET @local_variable be used for variable assignment rather than SELECT @local_variable.

Examples
declare @i int
set @i=1
This is used to assign constant values.

select @i=max(column_name)from table_name
for ex.
select @i=max(emp_id) from table_emp.

72. What is the difference between char , varchar and nvarchar?
 

char(n)Fixed length non unicode character data with length of n bytes.n must be a value from 1 through 8,000.

varchar(n)variable length non unicode character data with length of n bytes.

nvarchar(n)variable length unicode character data of n characters. n must be a value from 1 through 4,000.

73. How many types of triggers are there?
 
    There are three types of triggers.
  • DML Triggers
    --> AFTER Triggers
    --> INSTEAD OF Triggers
  • DDL Triggers
  • CLR Triggers
123456789101112131415

Page 14 of 15