Export Gridview to Excel asp.net 2.0

,
It is easy to make excel file of gridview just copy and paste the following code to your csharp code and change the gridview name. It will generate the excel sheet easily. please don't forget to give comments

protected void Button1_Click(object sender, EventArgs e)
{
HtmlForm form = new HtmlForm();
string attachment = "attachment; filename=Employee.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form.Controls.Add(gvContact);
this.Controls.Add(form);
form.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}

How to get duplicate records from the Database

,
We have to use the group by with having command to get the duplicate values. this query shall show the result of only the users have duplicate values in the employee table.

SELECT columnName FROM TableName
Group By columnName
Having Count(*)>1