Showing posts with label friends. Show all posts
Showing posts with label friends. Show all posts

Wednesday, March 21, 2012

Exporting a table to a file -reg

Dear Friends,
I am having Sql Server 2005 Express Edition. Also I have installed "Sql
Server Management Studio Express".
In "Sql Server Management Studio Express", how to export a table to a csv
file, or to another table?
Thanks & Regards,
Thirumalai.Hi
Use AdventureWorks
--Import to another table
SELECT * INTO Person.Address_New FROM
Person.Address
SELECT * FROM Person.Address_New
--Import to the file
exec master..xp_cmdshell 'BCP AdventureWorks.Person.Address_New OUT
c:\test1.txt -c -C850 -SSERVER\SQLSERVERDEV2005 -Usa -Ppwd'
"Thirumalai" <thirumalai@.cspl.com> wrote in message
news:eiQpaM$SGHA.4452@.TK2MSFTNGP12.phx.gbl...
> Dear Friends,
> I am having Sql Server 2005 Express Edition. Also I have installed "Sql
> Server Management Studio Express".
> In "Sql Server Management Studio Express", how to export a table to a csv
> file, or to another table?
> Thanks & Regards,
> Thirumalai.
>
>

Friday, February 24, 2012

Export To Excel

Hi Friends,
I am generating a report using sql server reporting service and
rendering it in my .aspx page in a report viewer control. Now i need
to export it to excel so that the excel file can be stored in client
pc.How do i show an save as dialoge box,so that user can either
save,open or cancel.
Please help me out.
Thanks,
RanjanOn Feb 27, 12:26 am, "Ranj" <ranjan.raghaven...@.gmail.com> wrote:
> Hi Friends,
> I am generating a report using sql server reporting service and
> rendering it in my .aspx page in a report viewer control. Now i need
> to export it to excel so that the excel file can be stored in client
> pc.How do i show an save as dialoge box,so that user can either
> save,open or cancel.
> Please help me out.
> Thanks,
> Ranjan
You should be able to use something like the following (basically,
call a header):
------
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" +
Session["SpecialName"].ToString() + "NameOfExcelSpreadsheet.xls");
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
this.ObjectName.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
------
I'm not certain this will work in the Report Viewer itself though. You
might need to add a button/etc to accomplish this outside the report
viewer. Hope this helps.
Regards,
Enrique Martinez
Sr. ASP.NET/SQL Server Developer