DATABASE | SQL SERVER | SQL SERVER INTERVIEW QUESTION AND ANSWERS 10 | WHAT IS THE DIFFERENCE BETWEEN SET AND SELECT? , WHAT IS THE DIFFERENCE BETWEEN CHAR , VARCHAR AND NVARCHAR? | HOW MANY TYPES OF TRIGGERS ARE THERE?

SQL Server Interview Question and Answers:

45.     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.

46.     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.
 
47.     How many types of triggers are there?
    There are three types of triggers.
    DML Triggers
    --> AFTER Triggers
    --> INSTEAD OF Triggers
    DDL Triggers
    CLR Triggers

No comments:

Post a Comment