1. What is the difference between finally and finalize in csharp ?
Finally:
• It is use in exceptional handling.
• It uses with try-catch block
• It will always execute no matter try block get error.
• It is uses when we want particular code execute in any case.
• It is only one with one try block.
Finalize():
• The Finalize method is used to perform cleanup operations on unmanaged resources held by the
current object before the current object is destroyed.
• In C# destructor are converted to finalize method by C# compiler.
• The scope of the Object.Finalize method is protected.
• The Finalize() destructor is called after the last reference to an object is released from the
memory.
• It is automatically called by garbage collector to release resource.
• The exact time when the finalizer executes during garbage collection is undefined.
What is the Difference between IN and Exists in SQL Server 2005? Give the brief
explanation?
using the IN clause, you're telling the rule-based
optimizer that you want the inner query to drive the outer
query (think: IN = inside to outside).
When you write EXISTS in a where clause, you're telling the
optimizer that you want the outer query to be run first,
using each value to fetch a value from the inner query
(think: EXISTS = outside to inside).
SELECT xyz FROM Table WHERE EXISTS (SELECT...)
If EXISTS subquery return one or more results, WHERE condition is evaluated as
TRUE, If subquery returns empty result set, WHERE condition is evaluated as
FALSE. No matter on returned data by subquery but only empty result or any
result.
SELECT xyz FROM Table WHERE column1 IN (1,2,3)
2. SELECT xyz FROM Table WHERE column1 IN (SELECT ....)
IN compare two values - column1 and all values returned by subquery or 1,2,3
values.