Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Export to Excel Syntax

Author  Topic 

Kluivert
Starting Member

1 Post

Posted - 2008-12-17 : 12:35:14
You have all seen this. Right?

Originally posted by madhivanan

Apart from using DTS and Export wizard, we can also use this query to export data from SQL Server2000 to Excel

Create an Excel file named testing having the headers same as that of table columns and use this query

insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testing.xls;',
'SELECT * FROM [SheetName$]') select * from SQLServerTable

To export data from Excel to new SQL Server table,

select *
into SQLServerTable FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testing.xls;HDR=YES',
'SELECT * FROM [Sheet1$]')

To export data from Excel to existing SQL Server table,

Insert into SQLServerTable Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testing.xls;HDR=YES',
'SELECT * FROM [SheetName$]')



Madhivanan

Failing to plan is Planning to fail


can i do this with excel 2007??

Questions
1. Can Someone explain in simple terms the syntax.
2. Depending on the office currently installed on my machine, how would i know the reference to excel i need to refer to. I mean, for example using office 2003. What would excel reference would i use and how would i check that supposing i upgrade to 2007 or use 2000?


Regards
David

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 12:48:46
see below

http://www.connectionstrings.com/excel

http://www.connectionstrings.com/excel-2007
Go to Top of Page
   

- Advertisement -