473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to export sql server-2005 table data into excel sheet

How to export sql server-2005 table data into excel sheet ..

Can u tell me how can i do this both my manually and by programmewise using perl

please help me...

thanks
Sangeetha.S
Mar 20 '08 #1
5 21798
deepuv04
227 Expert 100+
How to export sql server-2005 table data into excel sheet ..

Can u tell me how can i do this both my manually and by programmewise using perl

please help me...

thanks
Sangeetha.S
Hi,
Assume the table is Users.

use the following query to export data into excel sheet.
Make sure that the excel sheet must be on the server and the excel sheet has appropriate column headings at the first row.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO
  2.     OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
  3.                 'Excel 8.0;Database=D:\Test.xls',
  4.                 'SELECT UserId, UserName, FirstName,LastName FROM [Sheet1$]')
  5.     SELECT UserId, UserName, FirstName,LastName FROM Users 
  6.  
Mar 20 '08 #2
Hi,

thanks for ur reply..
But if i try ur coding the below mentioned error msg is apperring..
So wat i have to do to rectify this.
thnks
Sangeetha.S
P.S.our Db is centralised...


Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.









Hi,
Assume the table is Users.

use the following query to export data into excel sheet.
Make sure that the excel sheet must be on the server and the excel sheet has appropriate column headings at the first row.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO
  2.     OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
  3.                 'Excel 8.0;Database=D:\Test.xls',
  4.                 'SELECT UserId, UserName, FirstName,LastName FROM [Sheet1$]')
  5.     SELECT UserId, UserName, FirstName,LastName FROM Users 
  6.  
Mar 21 '08 #3
ck9663
2,878 Expert 2GB
By default OPENROWSET is not enabled in most sql-server installation. Talk to your sys-ad or dba to enable it.

-- CK
Mar 21 '08 #4
deepuv04
227 Expert 100+
Hi,

thanks for ur reply..
But if i try ur coding the below mentioned error msg is apperring..
So wat i have to do to rectify this.
thnks
Sangeetha.S
P.S.our Db is centralised...


Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
Hi,
run the following script and then execute your query

Expand|Select|Wrap|Line Numbers
  1.     sp_configure 'show advanced options', 1
  2.     RECONFIGURE
  3.     GO
  4.     sp_configure 'Ad Hoc Distributed Queries', 1
  5.     RECONFIGURE
  6.     GO
  7.  
Thanks
Mar 24 '08 #5
Hi,
run the following script and then execute your query

Expand|Select|Wrap|Line Numbers
  1.     sp_configure 'show advanced options', 1
  2.     RECONFIGURE
  3.     GO
  4.     sp_configure 'Ad Hoc Distributed Queries', 1
  5.     RECONFIGURE
  6.     GO
  7.  
Thanks



Hi,

It is very helpful to me..
Thanks for ur help...

Sangeetha.S
Mar 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bose | last post by:
Hi I have to make export of SQL Server Database to MS Access and I have done it with the tables but now I need to transfer(export) the relations, keys and indexes. Can any1 tell me how to read...
3
by: Colin Graham | last post by:
Error when attempting to export Crystal Report as PDF document asp.net. I get the following error. Error in File...
16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
6
by: Chris Cox | last post by:
I'm trying to put together a simple access database that will allow a friend to maintain a simple database of products/pictures/prices, which he can then export to html and upload to a website. ...
1
by: Holly | last post by:
I have a web page in C# that export the crystal report to pdf files. I can export the pdf files on my local driver but if I change the file path to a remote server, the program doesn't give any...
1
by: fishy | last post by:
Hi all, I'vw written an asp.net web application that works just fine on my personal machine but when i moved it to the server folder there is this exception i'm getting while using export method of...
0
by: TomH | last post by:
I am attempting to run a 2 computer upgrade from SQL Server 6.5 to SQL Server 2000 over a workgroup LAN. My experience with database systems is limited and I am certainly not a database...
5
by: JHNielson | last post by:
I have a somewhat simple question, but have been baffled by it for a while, and now I'm on a tight deadline - have to get it done within 24 hours. I am trying to export a set of files to my hard...
0
by: onlyforforum | last post by:
Hello, I have written the makefile and successfully produce the server exe. But, it doesn't run in hpux11.11 server. compile and link option: /opt/aCC/bin/aCC -Aa -Wl,+s...
3
by: rockmead76 | last post by:
Hi, I'm not a SQL person but have the need to export a tables content (from live) and then import into a test system. A backup and restore is not an option. bcp Database..databasetable out...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.