May 19, 2009 at 2:53 am
Hi,
I need the output of a particualr query in a flat file. How do i do it from the Stored Proc?
May 19, 2009 at 3:40 am
Using bcp or sqlcmd command utility in conjunction with xp_cmdshell procedure. For e.g.
EXECUTE master.dbo.xp_cmdshell 'sqlcmd -Q "SELECT * FROM AdventureWorks.Person.Contact" -o
MyOutput.txt'
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT FirstName, LastName FROM AdventureWorks.Person.Contact ORDER BY LastName, Firstname" queryout Contacts.txt -c -T'
Or even you can use OPENROWSET, OLE Automation Objects & Linked Servers.
--Ramesh
May 19, 2009 at 3:48 am
Hi Ramesh
Ramesh (5/19/2009)
...OLE Automation Objects...
:w00t:
... I really hope Active-X will die with CLR integration.
Greets
Flo
May 19, 2009 at 4:21 am
Florian Reischl (5/19/2009)
Hi RameshRamesh (5/19/2009)
...OLE Automation Objects...:w00t:
... I really hope Active-X will die with CLR integration.
Greets
Flo
:hehe:And I am hoping that Active-X should die with T-SQL.
I never was a fan of CLR and I hope never would want to be one.:-D
--Ramesh
May 19, 2009 at 4:31 am
Ramesh (5/19/2009)
Florian Reischl (5/19/2009)
Hi RameshRamesh (5/19/2009)
...OLE Automation Objects...:w00t:
... I really hope Active-X will die with CLR integration.
Greets
Flo
:hehe:And I am hoping that Active-X should die with T-SQL.
I never was a fan of CLR and I hope never would want to be one.:-D
CLR rocks for file handling! :laugh:
May 19, 2009 at 5:18 am
Florian Reischl (5/19/2009)
CLR rocks for file handling! :laugh:
Ya, I know CLR rocks with file handling, string manipulations etc., but I never really liked those .NET languages, 'cause I never succeeded in learning those.:crazy:
--Ramesh
May 19, 2009 at 6:44 am
Ramesh (5/19/2009)
Florian Reischl (5/19/2009)
CLR rocks for file handling! :laugh:Ya, I know CLR rocks with file handling, string manipulations etc., but I never really liked those .NET languages, 'cause I never succeeded in learning those.:crazy:
I guess the main problem for learning .Net are the available books. Most are huge compendiums which handle much more than really needed things for CLR in SQL.
A (still) good book is "Inside C#" which came out 2001. It doesn't cover all the cool things like LINQ, WCF, ... but it it covers the real needed things to understand .Net, nothing more.
May 19, 2009 at 6:54 am
In case you don't wanna learn C# or like me, just don't find the time to do it, there are two very good articles about reading from and writing to files on Simple Talk:
http://www.simple-talk.com/sql/t-sql-programming/the-tsql-of-text-files/
[font="Verdana"]Markus Bohse[/font]
May 19, 2009 at 7:44 am
Florian Reischl (5/19/2009)
Ramesh (5/19/2009)
Florian Reischl (5/19/2009)
CLR rocks for file handling! :laugh:Ya, I know CLR rocks with file handling, string manipulations etc., but I never really liked those .NET languages, 'cause I never succeeded in learning those.:crazy:
I guess the main problem for learning .Net are the available books. Most are huge compendiums which handle much more than really needed things for CLR in SQL.
A (still) good book is "Inside C#" which came out 2001. It doesn't cover all the cool things like LINQ, WCF, ... but it it covers the real needed things to understand .Net, nothing more.
Thank you, Flo, I really appreciate your help. On the contrary, I hope that you won't make me that firm to start learning CLR.:w00t:
--Ramesh
May 19, 2009 at 8:14 am
MarkusB (5/19/2009)
In case you don't wanna learn C# or like me, just don't find the time to do it, there are two very good articles about reading from and writing to files on Simple Talk:http://www.simple-talk.com/sql/t-sql-programming/the-tsql-of-text-files/
Thanks for links, Mark.
--Ramesh
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply