July 19, 2011 at 10:31 am
Hi Everyone,
I am gathering data from different SQL Server tables in my stored procedure and then loading the result into CSV file.
Right now I am using SSIS package to load data from Stored procedure to csv.
Is there any way that, I can directly load data from Stored proc to csv without using SSIS package.
I need the result like , whenever i run my stored Proc , it can load data into CSV.
Thanks in advance.
July 19, 2011 at 11:43 am
You could use OPENROWSET for example:
-- table to text file. Text file must have a first line of comma separated field names
--and select must be by column name
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0','Text;Database=C:\',
'SELECT * FROM Test.txt') --the text file to be to
-- columnname column name table name
SELECT KeywordId, Keyword FROM Keywords
--A short list of my results copied from C:\Test.txt
KeywordId,Keyword
"1","Discs"
"2","freespace"
"3","drives"
"4","UTC"
"5","Time"
"6","Constraints"
"7","Jobs"
"8","Commands"
"9","Last-commands"
"10","Role"
July 19, 2011 at 12:59 pm
Its giving me Error:
Error Msg:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.
July 19, 2011 at 1:21 pm
Download and install from:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5793
July 19, 2011 at 5:41 pm
Hi
You can also checkout bcp, it's as old as the mountains and blazingly fast.
It's also fairly simple to use
Cheers
Jannie
July 19, 2011 at 7:36 pm
krishusavalia (7/19/2011)
Its giving me Error:Error Msg:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.
Sorry for being so long in getting back to you.
Do you have Microsoft's EXCEL installed on your local machine, and/or the machine that has the text file installed. If not install Excel and the required driver will be installed. Now if ypu install the a version of Excell (2007 or later) the OPENROWSET command will have to modified to use Microsoft.ACE.OLEDB.12.0 instead of Microsoft.Jet.OLEDB.4.0
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply