NetProgrammingHelp.com
Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

Recent Posts

  • How to declare/use global constants (enum’s) in javascript ajax function
  • Silverlight Data Binding OneWay TwoWay Asp.Net C# XAML
  • Accessing Executing Running Stored Procedure/Function/Package Using Linq Silverlight Xaml
  • Creating/Developing Silverlight Data Driven Applications Using Wcf Linq Asp.Net C#
  • Deploying Manually Publish XBAP Wpf Browser Application in IIS Asp.Net C# XAML
  • Creating Server and client using remoting asp.net c#
  • Create/Build wcf autocomplete/autoextender textbox using database linq c# asp.net
  • Essentials for Creating/Developing/Programming silverlight project tools wpf xaml
  • Working with xml data type variable sql server 2008 asp.net c#
  • Encrypting Stored Procedure sql server 2008 asp.net c#
  • Exporting Copying Sending Sql Table data into Excel Using OpenRowSet/Sql Server

    Posted by James Categorized Under: SQL SERVER/ORACLE Add Comments

    Introduction:
    In this article,iam going to explain about how to export a sql table data into sql server using sql server 2008.

    Main:
    Before starting first we need to set the below configuration settings,

    EXEC sp_configure 'show advanced options', 1;
    GO RECONFIGURE;
    GO EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
    GO RECONFIGURE;

    The config option EXEC sp_configure ‘Ad Hoc Distributed Queries’, 1 allows you to run all open rowset queries,

    INSERT INTO OPENROWSET 
    ('Microsoft.Jet.OLEDB.4.0', 
     'Excel 8.0;Database=c:Emp_Details.xls;',
     'SELECT * FROM [Sheet1$]')SELECT * FROM EMP
     
    For (.XLSX) format
    INSERT INTO OPENROWSET ('Microsoft.ACE.OLEDB.12.0', 
                            'Excel 8.0;Database=c:Emp_Details.xlsx;'
                           ,'SELECT * FROM [Sheet1$]')SELECT * FROM EMP

    Conclusion:
    Hope this helps,
    Happy Coding.

    Leave a Reply