March 3, 2012

Difference between Stored procedure and User Functions


Fundamental difference between Stored procedure vs User Functions:
  • Procedure may return none or more values.Function must always return one value either a scalar value or a table.
  • Procedure have input,output parameters.Functions have only input parameters.
  • Stored procedures are called independently by EXEC command whereas Functions are called from within SQL statement.
  • Functions can be called from procedure.Procedures cannot be called from function.
  • Exception can be handled in Procedure by try-catch block but try-catch block cannot be used in a function.(error-handling)
  • Transaction management possible in procedure but not in function.

June 22, 2011

WCF interview

What are the important principles of SOA (Service oriented Architecture)?
What are ends, contract, address, and bindings?
Which specifications does WCF follow?
What are the main components of WCF?
Explain how Ends, Contract, Address, and Bindings are done in WCF?
What is a service class?
What is a service contract, operation contract and Data Contract?
What are the various ways of hosting a WCF service?
How do we host a WCF service in IIS?
What are the advantages of hosting WCF Services in IIS as compared to self-hosting?
What are the major differences between services and Web services?
What is the difference WCF and Web services?
What are different bindings supported by WCF?
Which are the various programming approaches for WCF?
What is one-way operation?
Can you explain duplex contracts in WCF?
How can we host a service on two different protocols on a single server?
How can we use MSMQ bindings in WCF?
Can you explain transactions in WCF?
What different transaction isolation levels provided in WCF?
Can we do transactions using MSMQ?
Can we have two-way communications in MSMQ?
What are Volatile queues?
What are Dead letter queues?
What is a poison message?

May 16, 2011

Differences between user controls and custom controls

This question is asked in every interview happens for asp.net in all organizations, article will help the interviewee (candidate).

 FactorsUser controlCustom control
DeploymentDesigned for single-application scenarios


Deployed in the source form (.ascx) along with the source code of the application


If the same control needs to be used in more than one application, it introduces redundancy and maintenance problems
Designed so that it can be used by more than one application


Deployed either in the application's Bin directory or in the global assembly cache


Distributed easily and without problems associated with redundancy and maintenance
CreationCreation is similar to the way Web Forms pages are created; well-suited for rapid application development (RAD)Writing involves lots of code because there is no designer support
ContentA much better choice when you need static content within a fixed layout, for example, when you make headers and footersMore suited for when an application requires dynamic content to be displayed; can be reused across an application, for example, for a data bound table control with dynamic rows
DesignWriting doesn't require much application designing because they are authored at design time and mostly contain static dataWriting from scratch requires a good understanding of the control's life cycle and the order in which events execute, which is normally taken care of in user controls

April 25, 2011

Increase SQL Server performance

Following are tips which will increase your SQl performance :-
  1.  Every index increases the time takes to perform INSERTS, UPDATES and DELETES, so the number of indexes should not be too much. Try to use maximum 4-5 indexes on one table, not more. If you have read-only table, then the number of indexes may be increased.308
  2.  Keep your indexes as narrow as possible. This reduces the size of the index and reduces the number of reads required to read the index.
  3. Try to create indexes on columns that have integer values rather than character values.
  4. If you create a composite (multi-column) index, the order of the columns in the key are very important. Try to order the columns in the key as to enhance selectivity, with the most selective columns to the leftmost of the key.
  5. If you want to join several tables, try to create surrogate integer keys for this purpose and create indexes on their columns.
  6. Create surrogate integer primary key (identity for example) if your table will not have many insert operations.
  7. Clustered indexes are more preferable than nonclustered, if you need to select by a range of values or you need to sort results set with GROUP BY or ORDER BY.
  8. If your application will be performing the same query over and over on the same table, consider creating a covering index on the table.
  9. You can use the SQL Server Profiler Create Trace Wizard with "Identify Scans of Large Tables" trace to determine which tables in your database may need indexes. This trace will show which tables are being scanned by queries instead of using an index.

April 23, 2011

what is Static Constructors?

Static Constructors: A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.

Static constructors have the following properties:


1. A static constructor does not take access modifiers or have parameters.
2. A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
3. A static constructor cannot be called directly.
4. The user has no control on when the static constructor is executed in the program.
5. A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.

Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the LoadLibrary method.