title: Export a table from SQL Server 2008 Database to excel using c#
body: <p>I want to export a table from SQL Server 2008 Database to Excel sheet with the same constraints that were in database schema.
  For example, if in database a column has a datatype of integer or varchar
  then in the excel sheet it should have same datatype and there should be an error message that should be displayed in excel sheet itself if someone tries to enter invalid data into the columns.</p>
  
  <p>I found a code script <a href="http://sql2005ted.blogspot.in/2012/02/exporting-sql-statement-to-excel-in-c.html" rel="nofollow">here</a> but it is not implementing the constraints. </p>