1. DOTNET Framework Difference FAQs-1.pdf
HTML-XML Difference Faqs.pdf
ASP.NET Difference FAQs.pdf
Design Patterns Difference FAQs.pdf
Dotnet Programming Concepts Difference FAQs.pdf
LINQ Difference FAQs.pdf
OOPs Difference FAQs.pdf
Sql Server Difference FAQs.pdf
WCF Difference FAQs.pdf
ADO.NET Difference FAQs-1.pdf
Comparative Chart of ASP.Net 2.0,3.0 and 3.5 Features.pdf
Difference Between ASP.Net 2.0 and ASP.Net 3.5.pdf
2. 1) What is the difference between CCW and RCW?
S.No CCW RCW
1 COM to .NET communication .NET to COM Communication happens
happens through COM Callable through Runtime Callable Wrapper
Wrapper
2) What are the differences between Dll and Exe?
S.No Dll Exe
1 Objects of Dlls can be created Objects of Exe cannot be created
2 Dll is In-Process Exe is Out-Process
3 It cannot be started as a standalone It can be started as a standalone
3) What are the differences between Managed Code and Unmanaged Code?
S.No Managed Code Unmanaged Code
1 It is executed under CLR It is not executed under CLR
2 It compiles to intermediate language It compiles directly to machine code
3 It provides services like security, It does not provide security, exception
exception handling, garbage handling, garbage collection etc
collection etc
4 It can access both managed and It can access only unmanaged code
unmanaged code
3. 1) What are differences between XML and HTML?
S.No XML HTML
1 XML provides user definable tags HTML provides defined set of tags
designed for web display
2 XML is content driven HTML is format driven
3 End tags are essential in a well End tags are not always
formed XML document. In a well required.<HTML> tag needs an
formed document, elements can be equivalent </HTML> tag but <br> tag
defined as single tag or a pair of tags does not require </br> tag
like <student/> or the <student>…
</student> pair
4 Quotes required around attribute Quotes are not required for the values
values of attributes
5 Slash required in empty tags Slash not required
6 XML is used for describing data HTML is used for designing pages
5. 1) What are the differences between Inline code and Code Behind Code?
S.No Inline code Code Behind Code
1 Its within .aspx file Its in a external class file
2 Dynamically compiled Compiled prior to deployment and
linked with .aspx file
2) What are the differences between Global.asax and Web.Config?
S.No global.asax web.config
1 It is a class file It is an XML file
2 There can be only one for an There can be many if under different
application sub-folders
3 Can have Application and Session Cannot have Application and Session
events events
4 Need to be recompiled when No need to compile when changes are
changes are made made
3) What are the Differences between Server.Transfer and Response.Redirect?
S.No Server.Transfer Response.Redirect
1 The navigation happens on the The navigation happens on the client-
server-side ,so client history is side ,so client history is updated
not updated
2 Data can be persist across the Context.Items loses the persistence
pages using Context.Item
collection
3 No Round-trips Makes a Round-trip
4 Has Good encapsulation No
4) What is the difference between a custom control and a user control?
S.No User Control Custom Control
1 Is a file with the .ascx extension Is a file with the .dll extension
2 Can be only used with the Can be used in any number of
application applications
3 Language dependent They are language independent, a
control
created in c# can be used in vb.net
4 Cannot be added to Visual studio Can be added to Visual studio Toolbox
Toolbox
5 Inherits from Server controls and We have to develop from scratch ,
easy to create so comparatively
difficult
6 Generally used for static content Used when dynamic content is
required
5) What is the difference between Caching and Application?
S.No Caching Application
1 Cache have expire policy Application does not have expire
policy
2 Cache does not require explicit Application require explicit locking
locking
3 Cache has the Property of timeout, Application variables exist as long as
6. which allows us to control the the application is alive
duration of the Objects so cached
4 Output can be cached in 4 ways, Application does not have options as
Page Output Caching like Cache object
Page Partial Caching
DataSource Caching
Data Caching
5 It is accessible to page level to all It is accessible to both page level and
the users application level to all the users
6) What is the difference between web farm and web garden?
S.No Web farm Web garden
1 A web application running on A web application running on a single
multiple servers is called a web server that has multiple CPUs is
farm called a web garden
7) What is the difference between Application and Session Events?
S.No Application Event Session Event
1 Application events are used to Session events are used to initialize
initialize objects and data that we data that we want to keep throughout
do want to make available to all individual sessions, but that we do not
the current sessions of our web want to share between sessions
application
8) What is the difference between Session Cookies and Persistent Cookies?
S.No Session Cookies Persistent Cookies
1 Session Cookies do not have Persistent Cookies have an expiration
expiration date date. The expiration date indicates to
the browser that it should write the
cookie to the client’s hard drive
9) What are the differences between Server Controls and HTML Controls?
S.No Server Controls HTML Controls
1 Server Controls can trigger HTML Controls can trigger only
control-specific events on the page-level events on server (postback)
server
2 Data entered in a server control is Data is not maintained in an HTML
maintained across requests. Server control. Data must be saved and
controls retain state restored using page-level scripts
3 The Microsoft .NET Framework HTML controls have HTML attributes
provides a set of properties for only
each server control. Properties
allows us to change the server
control’s appearance and behavior
within server-side code
4 Server controls automatically We must detect browser in code or
detect browser and adapt display write for least common denominator
as appropriate
10) What are the differences between ViewState and Hidden fields?
S.No ViewState Hidden fields
1 This is used for pages that will This is used for pages that will
postback to itself postback to itself or to another page
7. 2 This is built in structure for This is not an inbuilt structure
maintaining state of a page
3 Security is more as data is hashed, Security is less when compared to
compressed and encoded ViewState
11) What is the difference between SQL Cache Notification and SQL Cache Invalidation?
S.No SQL Cache Notification SQL Cache Invalidation
1 Using SQL Cache Notification, Using SQL Cache Invalidation, we
we can generate notifications can make a cached item invalid that
when the data of a database on depends on the data stored in a SQL
which a cached item depends server database, when the data in the
changes SQL server database is changed
12) What is the difference between absolute time expiration and sliding time expiration?
S.No Absolute time expiration Sliding time expiration
1 In absolute time expiration, a In sliding time expiration, the time for
cached item expires after the which the item is cached is each time
expiration time specifies for it, incremented by its expiration time if it
irrespective of how often it is is accessed before completion of its
accessed expiration time
13) What is the difference between adding items into cache through Add() method and
Insert() method?
S.No Cache.Add() Cache.Insert()
1 Cache.Add() method also returns Cache.Insert() method adds only the
an object representing the item we item in the cache
have added in the cache ,besides
adding the item in the cache
2 It is not possible to replace an We can replace an existing item in the
existing item in the cache using cache using the Cache.Insert() method
the Cache.Add() method
14) What is the difference between page-level caching and fragment caching?
S.No Page-level caching Fragment caching
1 In Page-level caching, we cache In Fragment caching, we cache parts
a whole page of the web page such as a user control
added to the web page
15) What is the difference between Label control and Literal control?
S.No Label control Literal control
1 Final HTML code of a Label Final HTML code of a Literal control
control has an HTML tag contains only text, which is not
surrounded by any HTML tag
16) What is the difference between HyperLink control and LinkButton control?
S.No HyperLink control LinkButton control
1 A HyperLink control do not have A LinkButton control have Click and
Click and Command events Command events, which can be
handled in the code behind file of the
web page
8. 17) What is the difference between an HtmlInputCheckBox control and an
HtmlInputRadioButton control?
S.No HtmlInputCheckBox control HtmlInputRadioButton control
1 We can select more than one We can select only a single
HtmlInputCheckBox control from HtmlInputRadioButton control from a
a group of HtmlInputCheckBox group of HtmlInputRadioButton
controls controls
18) How a content page differs from a master page?
S.No Content page Master page
1 A content page does not have A master page has complete HTML
complete HTML source code source code inside its source file
19) How will you differentiate a submaster page from a top-level master page?
S.No Submaster page Top-level master page
1 Like a content page, a submaster Top-level master page has complete
page also does not have complete HTML source code inside its source
HTML source code file
20) What is the difference between a page theme control and a global theme?
S.No Page theme Global theme
1 A page theme is stored inside a A global theme is stored inside the
subfolder of the App_Themes Themes folder on a web server
folder of a web application
2 It can be applied to individual web It can be applied to all the web sites
pages of the web application on the web server
21) What is the difference between a default skin and a named skin?
S.No Default skin Named skin
1 A default skin does not have a A named skin has a SkinId attribute
SkinId attribute
2 It is automatically applied to all It is applied to a control explicitly by
the controls of the same type setting the SkinId property of the
present on a web page control from the Properties window
22) Differentiate Globalization and Localization
S.No Globalization Localization
1 Globalization is the process of Localization is the process of
identifying the specific portion of configuring a web application to be
a web application that needs to be supported for a specific language or
different for different languages locale
and isolating that portion from the
core of the web application
23) What are the differences between web.config and machine.config?
S.No web.config machine.config
1 This is automatically created This is automatically installed when
when we create an ASP.Net web we install Visual Studio. Net
application project
2 This is also called application This is also called machine level
level configuration file configuration file
9. 3 We can have more than one Only one machine.config file exists
web.config file on a server
4 This file inherits setting from the This file is at the highest level in the
machine.config configuration hierarchy
10. Difference between Web site and Web application
S.No Web site Web application
1 Can mix vb and c# page in single We can't include c# and vb page in single
website. web application.
2 Can not establish dependencies. We can set up dependencies between
multiple projects.
3 Edit individual files after Can not edit individual files after
deployment. deployment without recompiling.
4 Right choice when one developer Right choice for enterprise environments
will responsible for creating and where multiple developers work unitedly for
managing entire website. creating,testing and deployment.
i.e.,In web site development, i.e.,In Web application, different different
decoupling is not possible. groups work on various components
independently like one group work on
domain layer, other work on UI layer.
5 Web site is easier to create than Web Web application is more difficult to create
application than a Web site
Difference between Local storage and cookies
S.No Local storage Cookies
1 Good to store large amount of data, Good for small amount of data, up to 4KB
up to 4MB
2 Easy to work with the JavaScript Difficult to work with JavaScript
3 Local storage data is not sent to the All data is transferred to and from server, so
server on every request (HTTP bandwidth is consumed on every request
header) as it is purely at the client
side
4 No way to specify the time out Can specify timeout period so that cookies
period as the Cookies have data are removed from browser
Difference between Session and Cache
S.No Session Cache
1 Ssession retains state per user Cache is used for retaining state for
application scoped items.
2 Items put into a session will stay Items in the cache can expire (will be
there, until the session ends removed from cache) after a specified
amount of time. And also there is no guaranty
that objects will not be removed before their
expiration times as ASP.NET remove items
from cache when the amount of available
memory gets small. This process is called as
Scavenging.
3 The session state can be kept external This is not the case with the cache.
(state server, SQL server) and shared
between several instances of our web
app (for load balancing).
11. Difference between Datalist and Repeater
S.No Datalist Repeater
1 Datalist supports multiple columns Repeater doesn't support multiple columns
displaying and using repeat columns display,no repeat columns property
property
2 Datalist supports styles for formating Repeater does not provide styles
templates data[headerstyle,...]
3 Datalist rendering output[html Repeater performanace is better than Datalist
content]will be slow compare with
repeater.
Summary:
If the requirement can achieve using repeater and datalist,choose repeater for better performance
12. 1. Difference between Factory Pattern and Abstract Factory Pattern
S.No Factory Pattern Abstract Factory Pattern
1 Create object through inheritance Create object through composition
2 Produce only one product Produce families of products
3 Implements code in the abstract creator Concrete factories implements factory
that make use of the concrete type that method to create product
sub class produces
2.Difference between Abstract Factory Pattern And Builder Pattern
S.No Builder Pattern Abstract Factory Pattern
1 In Builder Pattern, there will be one Abstract Factory Pattern will return the
Director class which will instruct Builder instance directly.
class to build the different
parts/properties of our object and finally
retrieve the object.
2 It will have reference to the created It does not keep the track of it's created
object. object.
3.Difference between Builder Pattern And Composite Pattern
S.No Builder Pattern Composite Pattern
1 It is used to create group of objects of It creates Parent - Child relations between
predefined types. our objects.
4.Difference between MVC and MVP
S.No MVP MVC
1 MVP is a bit more complex to MVC is easier to implement than MVP.
implement than MVC .Also, it has
additional layer for view interfaces.
2 The request is always received by the The request is received by the controller
View and delegated to the presenter which in turn gets the required data and
which in turn gets the data does the loads up the appropriate view
processing
3 The presentation and view logic an be The controller logic can be unit tested.
unit tested as the view is loosely Note: We can unit test view if we are using
coupled. Razor view engine. ASPX viewengine are
not that easily unit testable
4 MVP is best suitable for Windows MVC is best suitable for Web Programming.
Programming as the flow naturally tend
towards this pattern.
13. 5.Difference between Proxy Pattern and Observer Pattern
S.No Proxy Pattern Observer Pattern
1 The Proxy Pattern is used for wrapping a The Observer Pattern is used by a publisher
kind of special object with 1 or more object to notify subscriber objects with
other objects. information.
2 Either because we don't always have the The publisher object does not know the
wrapped object or because it needs to be subscribing objects - except that the
managed in a certain way that can be conform to a certain subscriber interface.
simplified via the proxy object(s). This is This is a very flexible pattern for
kind of a way to exchange the API of an distributing events, since those that wants to
existing class with a proxy class. We are listen on certain object has the power to do
not just talking events here, but whatever so without changing the code of the
kind of functionality to define via the publishing object.
proxy object instead of the real object.
6. Difference between Singleton Pattern and a static class
S.No Singleton Pattern static class
1 Singleton pattern maintains single We cannot create instance for static class.
instance.
2 A singleton can extend classes and A static class cannot .
implement interfaces. Note: It can extend classes, but it does not
inherit their instance members.
3 A singleton can be initialized lazily or A static class is generally initialized when it
asynchronously. is first loaded, leading to potential class
loader issues.
4 Singletons can be handled static class cannot be handled
polymorphically without forcing their polymorphically.
users to assume that there is only one
instance.
5 Singleton Class can have value when Static are always just shared and have no
Class object instantiated between server instance but multiple references.
and client, such a way if three client
want to have a shared data between them
Singleton can be used.Thats why
singleton class can be used for state
mangement in stateless scenarios like
shopping cart scenario.
6 We can pass singleton object as We cannot pass parameter in static class
parameter
7 Singleton provides flexibility and also Static classes once defined could not
provides sort of a mechanism to control accomodate any future design changes as by
object creation based on various design static classes are rigid and cannot be
requirements. They can be extended as extended.
well if need arises. In other words we
are not always tied to a particular
implementation. With Singleton we
14. have the flexibility to make changes as
when situation demands.
7.Difference between Strategy and Inversion of Control (IOC)
S.No Strategy Pattern Inversion of Control (IOC) Pattern
1 The strategy pattern is useful when we Inversion of Control/Dependency Injection
want classes to depend on the interface (IoC/DI) comes into play when we want the
rather than the implementation.And we concrete strategy implementation injected
can easily swap out behavior depending into a class. For example, we could use the
on which concrete implementation we DI Framework Ninject and configure it so
provide. that it will know which concrete strategy
implementation to inject into a class in
specific scenarios.
Note: Strategy is just one of the ways that
IOC is implemented
8.DIfference between IDictionary and Dictionary
S.No IDictionary Dictionary
1 IDictionary is just a contract, abstraction Dictionary is concrete implementation.
2 It is recommended for example to expect Argument or Property is not required for
as argument an IDictionary rather than Dictionary.
concrete Dictionary, or to expose
property of IDictionary rather than
Dictionary, because this promotes loose
coupling. Than we are able to change
underlying objects in the future without
affecting those who use your object.
9.Difference between Factory Pattern and Dependency Injection
S.No Factory Pattern Dependency Injection(DI)
1 Factory is used to create objects DI is used to move the responsibility of
creating an object outside the main code.
2 Some of the well known framework
available for DI are
1. Unity Application Block (Microsoft)
2. Ninject
3. StructureMap
4. Castle Windsor
5. Munq/Funq
6. Autofac
15. 10.Difference between String.Clone() and String.Copy() method
S.No String.Clone() String.Copy()
1 Returns a reference to this instance of Creates a new instance of String with the
String. same value as a specified String.
i.e., it gives pointer value(ie Current i.e., it creates an instance in Heap Memory
memory Reference) and gives pointer value(ie New Memory
Reference)
11.Difference between Strategy Pattern and Factory Pattern
S.No Strategy Pattern Factory Pattern
1 Strategy's sole intent to is to provide a Factory's sole purpose is to create objects .
mechanism to select different algorithm.
2 We cannot use "strategy" to create We can use "factory" to create objects of
objects of "factory". "strategy".
12.Difference between Proxy and Adaptor
S.No Proxy Pattern Adaptor Pattern
1 Proxy on the other hand represents a Adapter is used to adapt to incompatible
standin object for the real object. This is interfaces. It's more directed from the client
required when the real object is complex (those who consume the object) perspective.
to create, is not available, or for A client expects an interface to be of
authentication purpose. For e.g. web particular type and adapter plays a role in
service proxy, proxy authentication filling that gap.
server etc.
It's more from making it easier for the client
Proxy can be categorized into to adapt to other third party libraries within
there own by adapting to it.
Virtual Proxy
Remote Proxy
Protection Proxy
13.Difference between Decorator and Visitor
S.No Decorator Pattern Visitor Pattern
1 Decorator may have just a single object Visitor has a tree of objects to be worked
to customize. upon.
2 Decorator does not require a traverser Visitor requires a traverser for successful
for successful implementation. implementation.
3 Decorator pattern is a structural pattern Visitor pattern is Behavioral pattern that
that help us to add new function to an seperate the data structure from the
object in the run time , note that in the operation (functionality ) that work on it ,
run time not design time . this mean we can add different operation on
the same data structure
18. Difference between hash table and arraylist
S.No Arraylist Hash table
1 Array List is a List Hash Table is a map
2 Here, we can only add items to the list Here, we can add data with the key
3 Retrieving data using Arraylist is slower Retrieving by key in Hashtable is faster than
than Hashtable because If we want to retrieving in Arraylist because If we want to
find something in a arraylist we have to find something in a hashtable we dont have
go through each value in arraylist. to go through each value in hashtable,
instead search for key values and is faster.
Difference between Hash Table and Arrays
Hash Table Array
Hash table stores data as name,value pair. Array stores only value
To access value from hash table, we need to In array, to access value , we need to pass
pass name. index number.
We can store different type of data in hash In array ,we can store only similar
table, say int,string etc. type of data.
Difference between Dictionary and Hashtable
Dictionary Hashtable
Dictionary is a generic type Hashtable is not generic type.
In Dictionary we need to specify the types of Hashtable is a collection of name/value pairs
both the key and the corresponding value.The that are organised on the basis of hash code of
value represents the actual object stored and the the key being specified.
key represents a means to identify a particular
object.
In Dictionary public static members are type Hashtable is thread safe for use by multiple
safe but any instance members are not type reader threads and a single writing thread.
safe.
We cannot use Dictionary with Web Services We can use Hashtable withWeb Services
The reason is no web service standard supports
generic standard.
Dictionary is aster than Hashtable because It is slower than dictionary because to retrieve
boxing is not required. a value we must cast it as its actual type,
because it will be returned via object reference.
19. Difference between array and stack
Array Stack
An array can be multi-dimensional Stack is strictly one-dimensional
An array allows direct access to any of its With a stack, only the 'top' element is directly
elements accessible; to access other elements of a stack,
we must go through them in order, until we
get to the one we want
Difference between Stack and Heap
Stack Heap
Memory will be allocated at the compile time. Memory will be allocated at the run time.
Here the memory is allocated by the compiler. Here the memory is allocated by the user.
Memory will be allocated only in sequential Memory will be allocated in sequential
locations. locations and non- sequential locations.
The memory will also be deleted by the The memory must be deleted explicitly by the
compiler. user.
There is lot of chance of memory wastage. There is no chance of memory wastage if the
memory is handled perfectly.
Difference between Array and ArrayList
Array ArrayList
They are fixed length. They are resizable and variable length
They are compiled strong type collection. They are flexible and can accommodate any
data types.
Because arrays are of fixed size and strong In arraylist lots of boxing and unboxing are
type collection performance is faster. done there for its performance is slower.
Array is in the System namespace ArrayList is in the System.Collections
namespace.
Ex:Char[] vowel=new Char[]; Ex:ArrayList a_list=new ArrayList();
20. 1.Difference between for and foreach loop
S.No For loop Foreach loop
1 In case of for the variable of the loop is In case of Foreach the variable of the loop
always be int only. while be same as the type of values under the
array.
2 The For loop executes the statement or The Foreach statement repeats a group of
block of statements repeatedly until embedded statements for each element in an
specified expression evaluates to false. array or an object collection.
3 There is need to specify the loop We do not need to specify the loop bounds
bounds(Minimum, Maximum). minimum or maximum.
4 example: example:
using sytem; using sytem;
class class1 class class1
{ {
static void Main() static void Main()
{ {
int j=0; int j=0;
for(int i=0; i<=10;i++) int[] arr=new int[]
{ {0,3,5,2,55,34,643,42,23};
j=j+1; foreach(int i in arr)
} {
Console.ReadLine(); j=j+1;
} }
} Console.ReadLine();
}
}
2. Difference between Covariance and Contravariance
S.No Covariance Contravariance
1 Converting from a broader type to a Converting from a more specific type to a
specific type is called co-variance.If B broader type is called contra-variance. If B is
is derived from A and B relates to A, derived from A and B relates to A, then we
then we can assign A to B. Like A=B. can assign B to A. Like B= A. This is
This is Covariance. Contravariance.
2 Co-variance is guaranteed to work Contra-variance on the other hand is not
without any loss of information during guaranteed to work without loss of data. As
conversion. So, most languages also such an explicit cast is required.
provide facility for implicit conversion.
e.g. Converting from cat or dog to animal is
e.g. Assuming dog and cat inherits from called contra-variance, because not all
animal, when you convert from animal features (properties/methods) of cat or dog is
type to dog or cat, it is called co- present in animal.
variance.
3 Example:
21. class Fruit { }
class Mango : Fruit { }
class Program
{
delegate T Func<out T>();
delegate void Action<in T>(T a);
static void Main(string[] args)
{
// Covariance
Func<Mango> mango = () => new Mango();
Func<Fruit> fruit = mango;
// Contravariance
Action<Fruit> fr = (frt) =>
{ Console.WriteLine(frt); };
Action<Mango> man = fr;
}
}
4 Note:
1. Co-variance and contra-variance is possible only with reference types; value types
are invariant.
2. In .NET 4.0, the support for co-variance and contra-variance has been extended to
generic types. No now we can apply co-variance and contra-variance to Lists etc. (e.g.
IEnumerable etc.) that implement a common interface. This was not possible with
.NET versions 3.5 and earlier.
22. 3.Difference between IList and IEnumerable
S.No IList IEnumerable
1 IList is used to access an element in a IEnumerable is a forward only collection, it
specific position/index in a list. can not move backward and between the
items.
2 IList is useful when we want to Add or IEnumerable does not support add or remove
remove items from the list. items from the list.
3 IList can find out the no of elements in Using IEnumerable we can find out the no of
the collection without iterating the elements in the collection after iterating the
collection. collection.
4 IList does not support filtering. IEnumerable supports filtering.
4.Difference between IEnumerable and IQueryable
S.No IEnumerable IQueryable
1 IEnumerable exists in IQueryable exists in System.Linq
System.Collections Namespace. Namespace.
2 IEnumerable is best to query data from IQueryable is best to query data from out-
in-memory collections like List, Array memory (like remote database, service)
etc. collections.
3 While query data from database, While query data from database,
IEnumerable execute select query on IEnumerable execute select query on server
server side, load data in-memory on side with all filters.
client side and then filter data.
4 IEnumerable is suitable for LINQ to IQueryable is suitable for LINQ to SQL
Object and LINQ to XML queries. queries.
5 IEnumerable does not supports custom IQueryable supports custom query using
query. CreateQuery and Execute methods.
6 IEnumerable does not support lazy IQueryable support lazy loading. Hence it is
loading. Hence not suitable for paging suitable for paging like scenarios.
like scenarios.
7 Extension methods supports by Extension methods supports by IEnumerable
IEnumerable takes functional objects. takes expression objects means expression
tree.
8 IEnumerable Example
MyDataContext dc = new MyDataContext ();
IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S"));
list = list.Take(10);
Generated SQL statements of above query will be :
SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0
23. Note: In this query "top 10" is missing since IEnumerable filters records on client side
IQueryable Example
MyDataContext dc = new MyDataContext ();
IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S"));
list = list.Take(10);
Generated SQL statements of above query will be :
SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee]
AS [t0]
WHERE [t0].[EmpName] LIKE @p0
Note: In this query "top 10" is exist since IQueryable executes query in SQL server
with all filters.
5.Difference between IEnumerable and IEnumerator
S.No IEnumerable IEnumerator
1 The IEnumerable interface is a generic IEnumerator provides two abstract methods
interface that provides an abstraction and a property to pull a particular element in
for looping over elements. a collection. And they are Reset(),
In addition to providing foreach MoveNext() and Current The signature of
support, it allows us to tap into the IEnumerator members is as follows:
useful extension methods in the void Reset() : Sets the enumerator to its
System.Linq namespace, opening up a initial position, which is before the first
lot of advanced functionality element in the collection.
The IEnumerable interface contains an bool MoveNext() : Advances the enumerator
abstract member function called to the next element of the collection.
GetEnumerator() and return an interface object Current : Gets the current element in
IEnumerator on any success call. the collection
2 IEnumerable does not remember the IEnumerator does remember the cursor state
cursor state i.e currently row which is
iterating through
3 IEnumerable is useful when we have IEnumerator is useful when we have to pass
only iterate the value the iterator as parameter and has to remember
the value
25. 1.Difference between LINQ and SQL
S.No LINQ SQL
1 LINQ Stands for language SQL stands for Structured
integrated query. Query Language.
2 LINQ Statements are verified SQL statements can be used in a
during compile time. application gets verified for their
syntaxes only in the run time.
3 To use LINQ we can depend upon To use SQL we need to be familiar
our .Net Language syntaxes and with SQL syntaxes and also the pre-
also we can consume base class defined functions of SQL like
library functionalities. MAX,MIN,LEN and SUBSTRING
etc...
4 LINQ Statements can be As SQL statements execute on
debugged as they execute under Database server debugging of the code
framework environment. is not possible.
SQL .
2.Difference between LINQ to SQL and Entity Framework
S.No LINQ to SQL Entity Framework
1 It only works with Sql server. It works with variety of db products.
2 Used for rapid application Cannot used for rapid application
development. development.
3 It does not support for complex It provides support for complex type.
type.
4 It cannot generate db from model. It can generate db from model.
5 Mapping type ( class to single Mapping type ( class to multiple
table) tables)
6 We can query data using We can query data using esql,object
DataContext. services,entity client and linq to
entities.
Another Good Reference:
http://jinaldesai.net/linq-to-sql-vs-entity-framework/
(OR)
http://www.slideshare.net/jinaldesailive/linq-to-sql-vs-entity-framework-jinal-desai
26. 3.Difference between LINQ and Stored Procedures
S.No LINQ Stored Procedures
1 As LINQ is part of .NET, we can It is really very hard to debug the
use visual studio’s debugger to Stored Procedure
debug the queries
2 With LINQ everything gets With Stored Procedures, we need to
complied into single DLL hence provide an additional script for
deployment becomes easy. deployment
3 LINQ is type safe, so queries Stored Procedures are not type safe
errors are type checked at compile i.e., error can be caught only during
time.It is really good to encounter runtime.
an error when compiling rather
than runtime exception!
4 LINQ supports multiple databases With Stored Procedures which need to
be re-written for different databases.
5 LINQ supports abstraction which As Stored Procedures does not support
allows framework to add abstaction , so it is difficult to add
additional improvements like additional impovements like multi
multi threading. It is much threading
simpler and easier to add this
support through LINQ than Stored
Procedures.
6 LINQ queries need to compile Stored Procedures are ster thn LINQ
before execution.Therefore, LINQ because they are precompiled i.e.,
is slower than Stored Procedures. Stored Procedures have a predictable
execution plan.Therefore, if a stored
procedure is being executed for the
second time, the database gets the
cached execution plan to execute the
stored procedure.
4.Difference between LINQ to SQL and LINQ to Objects
S.No LINQ to SQL LINQ to Objects
1 LINQ to SQL needs a Data LINQ to Objects does not need any
Context object. The Data Context intermediate LINQ provider or API.
object is the bridge between LINQ
and the database.
2 LINQ to SQL returns data of type LINQ to Objects returns data of type
IQueryable<T> IEnumerable<T>.
27. 3 LINQ to SQL is translated to SQL LINQ to Objects does not need to be
by way of Expression Trees, translated.
which allow them to be evaluated
as a single unit and translated to
the appropriate and optimal SQL
statements.
4 LINQ to SQL is translated to SQL LINQ to Objects is executed in the
calls and executed on the local machine memory.
specified database
5.Difference between LINQ to SQL and LINQ to Entities
S.No LINQ to SQL LINQ to Entities
1 Does not support Conceptual Data Supports Conceptual Data Model
Model
2 Does not support Storage Schema Supports Storage Schema
3 Does not support Mapping Schema Supports Mapping Schema
4 Does not support New Data Access Supports New Data Access Provider
Provider
5 Does not support Non-SQL Server Supports Non-SQL Server Database
Database Support Support
6 Supports Direct Database Does not support Direct Database
Connection Connection
7 Does not support Multiple-table Supports Multiple-table Inheritance
Inheritance
8 Does not support Single Entity from Supports Single Entity from Multiple
Multiple Tables Tables
28. 1.Difference between LINQ to SQL and ADO.NET
S.No LINQ to SQL ADO.NET
1 Used for data handling with SQL Used for data handling with any
Server databases only. database: SQL
Server/Access/Oracle/Excel etc.
2 Uses the extension methods of Does not use the extension methods of
System.Linq.Queryable class. System.Linq.Queryable class.
3 Introduced in .net Framework 3.0 It is there since the .net Framework 1.0
4 DataContext is used for Database SqlConnection/OleDbConnection are
connectivity. used for database connectivity
5 Syntax and coding is somewhat Easier syntax and coding.
complex.
Note: Both LINQ TO SQL and ADO.NET have connected / disconnected modes of data
handling
2.Difference between LINQ and nHibernate
S.No LINQ nHibernate
1 LINQ is not an open-source nHibernate is an open source.
2 LINQ is an incomplete ORM tool nHibernate is an ORM tool
as it needs additional extensions.
3 LINQ is primarily a querying nHibernate has a limited querying
language language.
4 LINQ is much more useful in nHibernate is much more useful in
small applications where there is largel applications where there is
no massive dependence on massive dependence on databases.
databases.
5 With LINQ, database already With nHibernate, database does not
exists and the relationships and already exist and it needs to be defined
some programming will be .
dependent on how the database is
defined.
29. 3.Difference between LINQ and Entity Framework
S.No LINQ Entity Framework
1 Used for Rapid Application Used for Enterprise Development
Development
2 Works with objects in database Works with Conceptual model of
database
3 Mainly woks with SQL Server Works with all data sources
4 ".dbml" is created while using ".EDMX" is created while using Entity
LINQ to SQL Framework
31. 1) What are the differences between TypeOf() and GetType()?
S.No TypeOf() GetType()
1 Its an operator Its a method
2 Can't be overloaded Has lot of overloads
2) What are the differences between const and readonly?
S.No const readonly
1 It cannot be static It can be instance level or static
2 It is evaluated at design time It is evaluated at run time
3 It is initialized at declaration It is initialized at declaration or in
constructor
4 It must be of integral type or In addition, it can have complex types
enumeration with new keyword and enumerations are
not allowed
3) What are the Differences between Abstract Class and Interface?
S.No Abstract Class Interface
1 It can have implemented Methods It cannot have implemented Methods
2 A class can inherit only one abstract A Class can implement any number of
class Interfaces
3 We go for Abstract classes on such We go for Interface on such situations
situations where we need to give where we need to give common
common functionality for group of functionality for group of un-related
related classes classes
4 If we add a new method, then we can If we add a new method, then we need to
provide a default implementation and change all the existing work
so no need to make any change to
existing work
5 Static and Instance constants are Only Static constants are possible
possible
4) What are the differences between Structure and Class?
S.No Structure Class
1 It is value type It is reference type
2 It is stored on stack It is stored on heap
3 It does not support inheritance It supports inheritance
4 It is suitable for small data structure It is suitable for complex data structures
5) What are the differences between property and indexer?
S.No Property Indexer
1 A property can be static member An indexer is always an instant member
2 The get accessor of a property The get accessor of an indexer
corresponds to a method with no corresponds to the same formal parameter
parameters lists as the indexer
6) What are the differences between overloading and overriding?
S.No Overloading Overriding
1 Same name in same / derived class We need to provide different
but with different / type of parameter implementation than base class
2 Has different signature Has same signature
3 Otherwise called Compile-time Otherwise called Run-time Polymorphism
32. Polymorphism
7) What are the differences between Value Types and Reference Types?
S.No Value Types Reference Types
1 It is stored on stack It is stored on heap
2 It can be accessed directly It can be accessed through references
3 Life time of value type is determined Lifetime of reference type is managed
by lifetime of variable that contain by .net framework
them
4 Examples: All numeric data type, Examples: All arrays, String, Class types,
Boolean, char, Date, Structure, Delegate
enumerations
Note: Object is not any kind of type. You can create object of structure as well as Class
Are not type: Namespaces, Modules, Events, properties, procedures, variables, constants, &
fields.
33. Difference between Events and Delegates
S.No Events Delegates
1 Event can be used in an Delegate cannot be used in an
interface definition interface definition
2 Event can only be invoked from Delegates can be invoked from child
the class that declares it classes and clients.
3 Event comes with its pair of There is no pair of accessors concept
accessors i.e Add and Remove. in delegates.
An event is always assigned and
unassigned with a += and -=
operator.
4 Event has a restrictive signature Delegates do not have restrictive
and must always be of the form
signature as like events
Event (object source, EventArgs
args)
Difference between Class and Object
S.No Class Object
1 It is a datatype that contains the It is a chunk of memory that
programming logic. implements the class logic.
2 Class is visible in the source code Object is in the RAM and not
and resides in hard disk. visible in source code.
3 Class is like a template or blueprint It is the real world implementation
of the object. It implements of the class. Each object has its
reusability,encapsulation, own copy of data.
inheritance
4 Example:Button is a class with Example: Button1, Button2 are the
properties like Text,BackColor, objects of Button class.
events like click, methods like
Focus
5 We can create subclasses We cannot create sub-objects
Difference between Private and Static Constructor
S.No Static constructor Private constructor
1 A static constructor is called Private constructor is called after the
before the first instance is instance of the class is created.
created. i.e. global initializer.
2 Static constructor will be called Static members will not be initialized
first time when the class is either by private or public
referenced.Static constructor is constructor.
used to initialize static members
of the class.
3 The static constructor will only be The private constructor will be
executed once. executed each time it is called.
34. Difference between properties and methods
S.No Properties Methods
1 Properties are used to represent Methods are used to performs actions
data
2 Properties are created by using Methods create like public void
getter and setter i.e., get{} and method1(parameter list here)
set{}
Difference between Singleton Pattern and a static class
S.No Singleton Pattern static class
Singleton pattern maintains single We cannot create instance for static
instance. class.
2 A singleton can extend classes and A static class cannot .
implement interfaces. Note: It can extend classes, but it
does not inherit their instance
members.
3 A singleton can be initialized lazily A static class is generally initialized
or asynchronously. when it is first loaded, leading to
potential class loader issues.
4 Singletons can be handled static class cannot be handled
polymorphically without forcing polymorphically.
their users to assume that there is
only one instance.
5 Singleton Class can have value Static are always just shared and have
when Class object instantiated no instance but multiple references.
between server and client, such a
way if three client want to have a
shared data between them
Singleton can be used.Thats why
singleton class can be used for
state mangement in stateless
scenarios like shopping cart
scenario.
6 We can pass singleton object as We cannot pass parameter in static
parameter class
7 Singleton provides flexibility and Static classes once defined could not
also provides sort of a mechanism accomodate any future design
to control object creation based on changes as by design static classes
various requirements. They can be are rigid and cannot be extended.
extended as well if need arises. In
other words we are not always tied
to a particular implementation.
With Singleton we have the
flexibility to make changes as when
situation demands.
36. Difference between Abstraction and Encapsulation
Abstraction Encapsulation
Abstraction solves the problem in the Encapsulation solves the problem in the
design level. implementation level.
Abstraction is used for hiding the Encapsulation means hiding the code
unwanted data and giving relevant data. and data into a single unit to protect the
data from outside world.
Abstraction allows us to focus on what Encapsulation means hiding the internal
the object does instead of how it does it details or mechanism of how an object
does something.
Abstraction- Outer layout, used in Encapsulation- Inner layout, used in
terms of design. terms of implementation.
For Example:- For Example:- Inner Implementation
Outer Look of a Mobile Phone, like it detail of a Mobile Phone, how keypad
has a display screen and keypad buttons button and Display Screen are
to dial a number.
connected with each other using circuits
Difference between Composition and Aggregation
Composition Aggregation
Defines a strong-coupled relationship Defines a weak-coupled relationship
between two entities, where the one between two entities, where one entity
entity is part of another, and both need could be part of another, but either can
each other for their existence. exist without the other, independantly.
e.g. Human body and the Heart. e.g.School and teacher.
Composition implies real ownership of Aggregation does not necessarily own
its components any of its aggregates.
Composition has a stronger bond of its Aggregation has weaker or looser bonds
components. with its aggregates.
Composition has components that exist Aggregation has aggregates that live at
at the inner level. the outer level.
37. Difference between Private Class and Sealed Class
Private Class Sealed Class
A Private class can only be accessed by A Sealed class can be accessed by any
the class it is defined and contain within class.Private Constructor of a Private
- it is completely inaccessible to outside Class = Sealed Class.
classes.
In private Class,we can create a In Sealed class we can not create a
constructor and therefore we can create constructor of that class, so no instance
an instance of that class. of that class is possible.
public class A public sealed class A
{ {
private class B }
{ public class B : A //ERROR
} {
B b = new B(); }
}
public class C
{
A.B b = new A.B(); // ERROR
}
The main use of Private class is to create The sealed classes are mainly used to
a user-defined type, which we want to be prevent inheritance features of object
accessible to that class only. oriented programming.
Private class(i.e private constructor) is
also used to implement singleton
classes(pattern). Singleton means "A
single-instance object, and it simplify
complex code. Singletons have a static
property that we must access to get the
object reference."
Difference between Static Class and Sealed Class
Static Class Sealed Class
We can neither create their instances, We can create their instances, but cannot
nor inherit them inherit them
They can have static members only. They can contain static as well as
nonstatic members.
ex: ex:
static class Program
38. { sealed class demo
{
}
}
class abc:demo
{
--Wrong
}
Static classes are used when a class The sealed classes are mainly used to
provides functionality that is not specific prevent inheritance features of object
to any unique instance. oriented programming.
Difference between Virtual method and Abstract method
Feature Virtual method Abstract method
Overriding Virtual method may or may An abstract method should be
not override by inherited class. overriden by inherited class.
i.e.,Virtual method provide i.e.,Abstract method forces
the derived class with the the derived class to
option of overriding it. override it.
Virtual = = Overridable abstract == MustOverride
Implementation Virtual method has an Abstract method does not
implementation. provide an implementation.
Necessity to Virtual methods allow Abstract methods in a
Implement subclasses to provide their class contain no method
own implementation of that body, and are implicitly
method using the override virtual
keyword
Scope Virtual methods scope to Abstract method's scope to
members only. members and classes
Instancing Virtual methods - Not Abstract method - direcly
applicable, as we can't NO, but other way, Yes.
create instance for We can create an instance
members, it is possible only of a class that derives from
with classes. an abstract class. And we
can declare a type Abstract
class and instantiate that
as a derived class.
39. Example:
public abstract class Test
{
public abstract void A(); // Abstract method
public virtual void B()
{
Console.WriteLine("Test.B"); } // Virtual Method
}
public class InheritedTest : Test
{
public override void A()
{
Console.WriteLine("InheritedTest.A");
}
//Method B implementation is optional
public override void B()
{
Console.WriteLine("InheritedTest.B");
}
}
Difference between Class and Static Class
Class Static Class
Class has Instance Members Static class does not have Instance
Members
In Class, Constructor has Access In Static Class, Constructor does not
Specifier. have Access Specifier.
In Class Constructor, initiation is done In Static Class ,Constructor will be
every time when an object is created called only one time .
for the class
In Class, Class members can be In Static Class, members can be
accessed through class object. accessed through its Class name only
40. Difference between Method Overloading and Method overriding in C#
Method Overloading Method overriding
Method Overloading is passing same Method Overriding is redifining parent
message for different functionality class function to the child class
Method Overloading is between the Method Overriding is between the same
same function name with the different method.
signature
Method Overloading does not check for Method Overriding checks the return
the return type. type.
Method Overloading takes place in the Method Overriding takes place between
same class. parent and child classes
Method Overloading is static binding Method Overriding is a dynamic
binding.
41. SQL Server Difference FAQs-1.pdf
SQL Server Difference FAQs-2.pdf
SQL Server Difference FAQs-3.pdf
SQL Server Difference FAQs-4.pdf
SQL Server Difference FAQs-5.pdf
42. 1) What are the Differences between TRUNCATE and Delete?
S.No Truncate Delete
1 Truncate is faster Delete is comparatively slower
2 Removes all rows from a table Can remove specific rows with Where
clause
3 Is DDL Command Is DML Command
4 Resets identity of the table Does not reset identity of the table
5 Removes the data by deallocating Removes one row at a time and
the data pages and logs the records an entry in the transaction log
deallocation. for each deleted row.
6 Cannot be rolled back Can be rolled back
2) What are the differences between Primary key and Unique key?
S.No Primary Key Unique Key
1 Creates Clustered index Creates Non-Clustered index
2 Null values are not allowed Allows only one null value
3) What are the Differences between Clustered Indexes and Non-Clustered Indexes?
S.No Clustered Indexes Non-Clustered Indexes
1 It reorders the physical storage of It sorts and maintain a separate
records in the table storage
2 There can be only one Clustered More than one
index per table
3 The leaf nodes contain data The leaf node contains pointer to data
4) What are the differences between Stored Procedures and User Defined Functions?
S.No Stored Procedures User Defined Functions
1 Stored Procedure cannot be used User Defined Function can be used in
in a Select statement a Select statement
2 Stored procedure supports User Defined Function does not
Deferred Name Resolution support Deferred Name Resolution
3 Stored Procedures are generally User Defined Functions are generally
used for performing Business used for Computations
Logic
4 Stored Procedure need not return User Defined Functions should return
a value a value
5 Stored Procedures can return any User Defined Functions cannot return
datatype Image
6 Stored Procedures can accept User Defined Functions accept lesser
more number of input parameters number of input parameters than
than User Defined Functions. Stored Procedures. UDF can have
Stored Procedures can have upto upto 1023 input parameters
21000 input parameters
7 Stored Procedures can use Temporary Tables cannot be used in a
Temporary Tables User Defined Function
8 Stored Procedures can execute User Defined Functions cannot
Dynamic SQL execute Dynamic SQL
9 Stored Procedure supports error User Defined Function does not
handling support error handling.
RAISEERROR or @@ERROR are
43. not allowed in UDFs
10 Non-deterministic functions can Non-deterministic functions cannot be
be used in Stored Procedures. used in User Defined Functions
(UDFs). For example, GETDATE()
cannot be used in User Defined
Functions(UDFs)
5) What are the differences between Where and Having clauses?
S.No Where clause Having clause
1 It applies to individual rows It applies to a group as a whole
2 It selects rows before grouping It selects rows after grouping
3 It cannot contain aggregate It can contain aggregate functions
functions
4 It can be used in select, delete It is used only in select clause
,insert etc.
6) What are the differences between Union and UnionAll?
S.No Union UnionAll
1 This is used to eliminate duplicate It will not eliminate duplicate rows
rows
2 This selects only distinct rows It selects all the values
3 It can be used to combine any It can be used to combine maximum
number of queries of 2 queries
4 It cannot contain aggregate It can contain aggregate functions
functions
7) What is the difference between normal Select statement and a Cursor?
S.No Select statement Cursor
1 Select statements are used for Cursors are used for row-level
table-level processing processing
44. 1) What are the differences between Instead of Triggers and After Triggers?
S.No Instead of Triggers After Triggers
1 Each table or view can have one A table can have several AFTER
INSTEAD OF trigger for each triggers for each triggering action.
triggering action (UPDATE,
DELETE, and INSERT)
2 INSTEAD OF triggers fire in AFTER triggers fire after the
place of the triggering action and triggering action (INSERT, UPDATE,
before constraints are processed. or DELETE) and after any constraints
are processed.
2) What are the differences between Views and User-Defined Functions?
S.No Views User-Defined Functions
1 Views cannot accept parameters. User-Defined Functions can accept
parameters.
2 Output of the Views cannot be Output of the User-Defined Functions
directly used in the SELECT can be directly used in the SELECT
clause. clause.
3) What are the differences between Triggers and Stored Procedures?
S.No Triggers Stored Procedures
1 Triggers cannot return a value Stored Procedures may return a value
2 We cannot pass parameters in We can pass parameter in Stored
Triggers Procedures
3 We can write a Stored procedure We cannot write a Trigger within a
within a Trigger Stored Procedure
4 Triggers are implicitly fired Stored Procedures need to be
whenever insert, update or delete explicitly called by the programmer
operations take place on table
5 Triggers can only be implemented Stored procedures can be written for
on Tables or Views the Database
45. 1.Difference between Identity and Sequence in SQL Server 2012
S.No Identity Sequence
1 Dependant on table. Independent from table.
2 Identity is a property in a table. Sequence is an object.
Example : Example :
CREATE TABLE Table CREATE SEQUENCE [dbo].
test_Identity [Sequence_ID]
( AS [int]
[ID] int Identity (1,1), START WITH 1
[Product Name] varchar(50) INCREMENT BY 1
) MINVALUE 1
MAXVALUE 1000
NO CYCLE
NO CACHE
3 If we need a new ID from an In the sequence, we do not need to
identity column we need to insert new ID, we can view the new ID
insert and then get new ID. directly.
Example : Example :
Insert into [test_Identity] Values SELECT NEXT VALUE
(‘SQL Server’) FOR dbo.[Sequence_ID]
GO
SELECT @@IDENTITY AS
‘Identity’
–OR
Select SCOPE_IDENTITY() AS
‘Identity’
4 We cannot perform a cycle in In the sequence, we can simply add
identity column. Meaning, we one property to make it a cycle.
cannot restart the counter after a
particular interval. Example :
ALTER SEQUENCE [dbo].
[Sequence_ID]
46. CYCLE;
5 We cannot cache Identity column Sequence can be easily cached by just
property. setting cache property of
sequence. It also improves the
performance.
Example :
ALTER SEQUENCE [dbo].
[Sequence_ID]
CACHE 3;
6 We cannot remove the identity The sequence is not table dependent so
column from the table directly. we can easily remove it
Example :
Create table dbo.[test_Sequence]
(
[ID] int,
[Product Name] varchar(50)
)
GO
–First Insert With Sequence object
INSERT INTO dbo.test_Sequence
([ID],[Product Name]) VALUES
(NEXT VALUE FOR [Ticket] ,
‘MICROSOFT SQL SERVER 2008′)
GO
–Second Insert without Sequence
INSERT INTO dbo.test_Sequence
([ID],[Product Name]) VALUES (2 ,
‘MICROSOFT SQL SERVER 2012′)
7 We cannot define the maximum Here we can set up its maximum
value in identity column it is value.
based on the data type limit.
Example :
47. ALTER SEQUENCE [dbo].
[Sequence_ID]
MAXVALUE 2000;
8 We can reseed it but cannot We can reseed as well as change the
change the step size. step size.
Example : Example :
DBCC CHECKIDENT ALTER SEQUENCE [dbo].
(test_Identity, RESEED, 4) [Sequence_ID]
RESTART WITH 7
INCREMENT BY 2;
9 We cannot generate range from We can generate a range of sequence
identity. values from a sequence object with the
help of sp_sequence_get_range.
2.Difference between Temp table and Table variable
S.No Temp table Table variable
1 A Temp table is easy to create and But the table variable involves the
back up data. effort when we usually create the
normal tables.
2 Temp table result can be used by But the table variable can be used by
multiple users. the current user only.
3 Temp table will be stored in the But a table variable will store in the
tempdb. It will make network physical memory for some of the data,
traffic. When we have large data then later when the size increases it
in the temp table then it has to will be moved to the tempdb.
work across the database. A
Performance issue will exist.
4 Temp table can do all the DDL Whereas table variable won't allow
operations. It allows creating the doing the DDL operations. But the
indexes, dropping, altering, etc.., table variable allows us to create the
clustered index only.
5 Temp table can be used for the But the table variable can be used up
current session or global. So that a to that program. (Stored procedure)
multiple user session can utilize
the results in the table.
6 Temp variable cannot use the But we cannot do it for table variable.
48. transactions. When we do the
DML operations with the temp
table then it can be rollback or
commit the transactions.
7 Functions cannot use the temp But the function allows us to use the
variable. More over we cannot do table variable. But using the table
the DML operation in the variable we can do that.
functions .
8 The stored procedure will do the Whereas the table variable won't do
recompilation (can't use same like that.
execution plan) when we use the
temp variable for every sub
sequent calls.
Another Good Reference:
http://sqljunkieshare.com/2011/11/05/difference-between-temporary-tables-and-table-variables/
3.Difference between RAISERROR and THROW statements
S.No RAISERROR Statement THROW Statement
1 If a msg_id is passed to The error_number parameter does not
RAISERROR, the ID must be have to be defined in sys.messages.
defined in sys.messages.
2 The msg_str parameter can The message parameter does not
contain printf formatting styles. accept printf style formatting.
3 The severity parameter specifies There is no severity parameter. The
the severity of the exception. exception severity is always set to 16.
4.Difference between Local temporary table and Global temporary table
S.No Local temporary table Global temporary table
1 Denoted by # symbol. Denoted by ## symbol.
2 Valid for the current connection Available to all the connections once
only. They are cleared as soon as created. They are deleted when all
the current connection closes. users referencing the table disconnect
from SQL Server .
3 Cannot be shared between Can be shared between multiple users.
multiple users.
49. 1.Difference between Correlated subquery and Nested subquery
S.No Correlated subquery Nested subquery
1 Correlated subquery runs once for Nested subquery runs only once for the
each row selected by the outer entire nesting (outer) query. It does not
query. It contains a reference to a contain any reference to the outer
value from the row selected by the query row.
outer query.
2 Correlated subquery follows down Nested subquery follows top-down
to top approach i.e., main query approach i.e., child query is executed
is executed first(even though first and then parent .
parenthesis are present) and then
child query. We can also say:In a subquery
Outer query condition is used in the
We can also say: in a Correlated the inner query.
subquery,Inner query condition is
used in the outer query
4 Example: Example:
select e1.empname, e1.basicsal, select empname, basicsal, deptno from
e1.deptno from emp e1 emp
where e1.basicsal = (select where (deptno, basicsal) in (select
max(basicsal) from emp e2 where deptno, max(basicsal) from emp group
e2.deptno = e1.deptno) by deptno)
2.Difference between Weak Entity Set and Strong Entity Set
S.No Weak Entity Set Strong Entity Set
1 An entity set which does not An entity set which does have a
possess sufficient attributes to primary key is called a strong entity
form a primary key is known as a set.
weak entity set.
2 Member of a weak entity set is a Member of a strong entity set is a
subordinate entity. dominant entity.
3 Example: Example:
Specific Set of all
Person,Company,Event,Plant Persons,Companies,Trees,Holidays
50. 3.Difference between char and varchar data types in Sql Server
S.No Char Varchar
1 Fixed length memory storage Variable length memory
storage(Changeable)
2 CHAR takes up 1 byte per VARCHAR takes up 1 byte per
character character, + 2 bytes to hold length
information
3 Use Char when the data entries in Use Varchar when the data entries in a
a column are expected to be the column are expected to vary
same size like phone number considerably in size like address
4 Ex: Ex:
Declare test Char(100); Declare test VarChar(100);
test="Test" - test="Test" -
Then "test" occupies 100 bytes Then "test" occupies only 4+2=6
first four bytes with values and bytes. first four bytes for value and
rest with blank data other two bytes for variable length
information.
4.Difference between Sql Server 2005 and Sql Server 2008
S.No Sql Server 2005 Sql Server 2008
1 XML datatype is introduced. XML datatype is used.
2 Cannot encrypt the entire Can encrypt the entire database
database. introduced in 2008.
3 Datetime is used for both date and Date and time are seperately used for
time. date and time
4 No table datatype is included. Table datatype introduced.
5 SSIS is started using. SSIS avails in this version.
6 CMS is not available. Central Management Server(CMS) is
Introduced.
7 PBM is not available Policy based management(PBM)
server is Introduced.
51. 1.Difference between Database Mail and SQL Mail
S.No Database Mail SQL Mail
1 Based on SMTP (Simple Mail Based on MAPI (Messaging
Transfer Protocol). Application Programming Interface).
2 Introduced in Sql Server 2005. Used prior versions of Sql Server
2005.
3 No need to install Outlook. Require Outlook to be installed.
4 More secure than Sql mail. Less secure than Database mail.
2.Difference between Azure Table storage and SQL Azure
S.No Azure Table storage SQL Azure
1 It is built on top of the Azure It is an SQL Server that has been
Storage platform. configured to be hosted on top
of the Windows Azure in a high
availability mode.
2 It comprises flexible or schema- It comprises standard SQL Tables with
less entities. No referential indexes and referential integrity.
integrity between the tables, and
no custom indexes.
3 It can scale massive amounts of It may not scale as far as Azure Table
data due to the partition key. storage.
4 Can be thought as single Look familiar to any .Net developer
spreadsheet. who has used Sql server 2008 prior.
3.Difference between DBMS and RDBMS
S.No DBMS RDBMS
1 Stands for DataBase Management Stands for Relational DataBase
System Management System
2 In dbms no relationship concept It is used to establish the relationship
concept between two database objects,
i.e, tables
3 It supports Single User only It supports multiple users
4 It treats Data as Files internally It treats data as Tables internally
5 It supports 3 rules of E.F.CODD It supports minimum 6 rules of
out off 12 rules E.F.CODD
6 It requires low Software and It requires High software and
52. Hardware Requirements. hardware requirements.
7 DBMS is used for simpler RDBMS is used for more complex
business applications applications.
8 DBMS does not impose any RDBMS defines the integrity
constraints or security with regard constraint for the purpose of holding
to data manipulation ACID PROPERTY
9 In DBMS Normalization process In RDBMS, normalization process
will not be present will be present to check the database
table consistency
10 There is no enforcement to use Although the foreign key concept is
foreign key concept compulsorily supported by both DBMS and RDBMS
in DBMS but its only RDBMS that enforces the
rules
11 FoxPro, IMS are Examples SQL Server, Oracle are examples
4.Difference between SQL Server 2000 and SQL Server 2005
S.No SQL Server 2000 SQL Server 2005
1 Query Analyser and Enterprise Both are combined as SSMS(Sql
manager are separate. Server management Studio).
2 No XML datatype is used. .XML datatype is introduced.
3 We can create maximum of We can create 2(pow(20))-1 databases.
65,535 databases.
4 Exception Handling mechanism is Exception Handling mechanism is
not available available
5 There is no Varchar(Max) data Varchar(Max) data type is introduced.
type is not available
6 DDL Triggers is not available DDL Triggers is introduced
7 DataBase Mirroring facility is not DataBase Mirroring facility is
available introduced
8 RowNumber function for paging RowNumber function for paging is
is not available introduced
9 Table fragmentation facility is not Table fragmentation facility is
available introduced
10 Full Text Search facility is not Full Text Search facility is introduced
available
53. 11 Bulk Copy Update facility is not Bulk Copy Update facility is
available introduced
12 Data Encryption concept is not .Cannot encrypt the entire database
introduced
13 Cannot compress the tables and Can Compress tables and indexes.
indexes. (Introduced in 2005 SP2)
14 No varchar(max) or Varchar(max) and varbinary(max) is
varbinary(max) is available. used.
15 Data Transformation SQL Server Integration Services(SSIS)
Services(DTS) is used as ETL tool is started using from this SQL Server
version and which is used as ETL tool