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)
 Creating Text File

Author  Topic 

irfanshirur
Starting Member

21 Posts

Posted - 2009-11-12 : 08:14:11


hi

I am trying to export the query result to a text file.

So using this query to export , its giving som error.

Query :

INSERT OPENROWSET('Microsoft.Jet.OLEDB.4.0','Text;Database=C:\SQL.txt',SINGLE_CLOB)
--query goes here
select top 5 * from schtasks


We need to create text file or it will create by default ?


Error :
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "'C:\SQL.txt' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".



Please can any one help me to resolve this issue.

Thanks
Regards
Mohammed Irfan



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-12 : 08:15:57
Note that the file shoule be in Server's directory

Madhivanan

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

irfanshirur
Starting Member

21 Posts

Posted - 2009-11-12 : 08:18:06

Thanks for the reply.

i am using my local SQL, and also created the file.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-12 : 08:50:30
Try this

INSERT OPENROWSET('Microsoft.Jet.OLEDB.4.0','text;HDR=YES;FMT=FixedLength;Database=c:\', SQL#txt)
select top 5 * from schtasks

Madhivanan

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

- Advertisement -