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 2005 Forums
 Transact-SQL (2005)
 T-SQL: Writing file to database table

Author  Topic 

im1dermike
Posting Yak Master

222 Posts

Posted - 2009-12-09 : 12:28:34
I know how to write a file (eg. *.xls) to a database table as a varbinary(max) using C#, but can it be done directly in T-SQL in a stored procedure?

Thanks

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-12-09 : 15:02:14
You can access and manipulate xls files by using openrowset.


select *
Into #Tmp
from
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;DATABASE=C:\Myfile.xls', 'Select * from [Sheet1$]') a




Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2009-12-09 : 15:53:44
Question:

I tried this for kicks, changing the path to one of my own, and I got the msg :

Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

Anyone know what this means?

(From what Ive looked up it appears the Jet OLEDB is not compatible with 64 bit SQL 2005??) Source:http://social.msdn.microsoft.com/Forums/en-IE/sqldataaccess/thread/60dc2b9a-eddb-4a13-8c87-e96655be9fca
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-12-09 : 18:50:25
The 64 bit dll Is available, just google it for the download link.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-10 : 01:50:01
After downloading the dll, still if you have any problems, refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -