ASP.NET LINQ Articles

Export SQL Data to Excel Sheet

First Run This Procedure

 EXEC sp_configure ‘show advanced options’, 1;

GO

RECONFIGURE;

GO

EXEC sp_configure ‘Ad Hoc Distributed Queries’, 1;

GO

RECONFIGURE;

GO

Create Excel sheet with two column

Column 1 is : FirstName

Column 2 is : LastName

Save Excel File as contact.xls

Create On Data Table with same column name

FirstName,LastName and save table as Contact

INSERT INTO OPENROWSET (‘Microsoft.Jet.OLEDB.4.0′, ‘Excel 8.0;Database=c:\contact.xls;’,

‘SELECT * FROM [Sheet1$]‘)

SELECT TOP 5 FirstName, LastName

FROM Contact

GO

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Tag Cloud

Follow

Get every new post delivered to your Inbox.