How to export data from sql server 2008 to excel and email as attachement I'm new. Can anyone advise how I can export data from database sql 2008 to excel and email as attachment?
You can use SSIS (SQL Server Integration Services). Simple example:


Control Flow task 1 - Data Flow:

OLEDB Source. Choose the source table/view/use a query...
Excel destination.

Control Flow task 2 - Send Mail Task. Attach the above generated Excel.


You can build the "Export from SQL to Excel" part also via the SQL Server Import and Export Wizard in BIDS. Check this video for a demo.
For the Send Mail Task, check this BOL article.

If you want to automate and schedule it, you can use a SQL Agent scheduled job with an SSIS job step. A video demo is available here.
If you automate it on a server, make sure Microsoft Access Database Engine 2010 Redistributable is installed (you do not need Excel there, just the "drivers").