Monday, August 29, 2011

Form based Authentication for Sharepoint 2010


This is my first Blog on Sharepoint and I am starting with Form Based Authentication.

See below video to checkout how to configure Form Based Authentication.

Wednesday, August 17, 2011

Remove Comma Separated value from SQL string

Declare @CommaSeparatedValue varchar(100)

set  @CommaSeparatedValue  = '1,2,3,4,5';

print @CommaSeparatedValue

Set  @CommaSeparatedValue = LEFT(REPLACE(@CommaSeparatedValue+ ',' ,CAST(3 as varchar) + ',',''),LEN(REPLACE(@CommaSeparatedValue + ',' ,CAST(3 as varchar)+ ',',''))-1)

Print  @CommaSeparatedValue

Wednesday, June 22, 2011

Remove Seconds from SQL Datetime and Get format (MM/dd/yyyy HH:mm dp)


Result will be like :
MM/dd/yyyy HH:mm AM/PM.

Enjoy Querying.....

Monday, June 20, 2011

Checkbox validation in Grid from Javascript

function validateCheckBoxes() {
      var isValid =false;
      var gridView= document.getElementById('<%= grdSearchResult.ClientID %>');

      for (var i = 1; i < gridView.rows.length; i++) {
           var inputs = gridView.rows[i].getElementsByTagName('input'); 
                      if(inputs != null) {
             if (inputs[0].type == "checkbox") {
                 if(inputs[0].checked) {
                      isValid = true; 
                      return true;


    alert("Please select at least 1 record in the grid.");

Tuesday, May 3, 2011

Creating Stored Procedure with Output Parameters

Creating Stored Procedure with Output Parameters 

Now we are going to use Output parameters in our Stored Procedure to return some value from it. Output parameters are created in the same space as the input parameters, right between the procedure name and AS sections. The only difference is that they are defined with the word OUTPUT immediately afterward. 

Open window for New Stored Procedure and add the following code in it,


@FirstNo varchar(50),

@SecondNo varchar(50),

@Result varchar(50) OUTPUT


SET @Result = @FirstNo + @SecondNo

Don’t worry, I am explaining you another type of example due to the reason that it is much easier to understand how OUTPUT parameters work.

Executing the Stored Procedure having OUTPUT parameters is very simple. Just create a local variable to hold the returned value and display it.

Here is the code


DECLARE @res int

EXEC Show_Customer 1,3 , @res OUTPUT

PRINT @res 

Monday, May 2, 2011

Candidate,Alternate and Composite Keys of SQL Server.

What are Candidate, alternate and composite keys?

A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.

A key formed by combining at least two or more columns is called composite key.

below is the example of Composite key.

Col1 int IDENTITY(1,1)
, Col2 char(1)
, Col3 datetime DEFAULT GetDate()
, Col4 int
, PRIMARY KEY (Col1, Col2)