Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
| Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 30th, 2007, 05:17 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Default Output Query to txt file from SQL Query

i have a stored procedure that involves couple joins of tables. what i want now is to save the result in a text file programmatically so that i can schedule a job that runs this procedure. i looked in google but i could not find a solution.

any help is appreciated
  #2 (permalink)  
Old October 30th, 2007, 06:30 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

What kind of text file??? CSV??? Tab Delimited??? Fixed Field??? Quoted Literal???

--Jeff Moden
  #3 (permalink)  
Old October 31st, 2007, 07:58 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i am looking for tab delimited file.
  #4 (permalink)  
Old November 1st, 2007, 07:34 AM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

I just realized this is a 2k5 forum, not 2k... I don't know how to use SSIS...

BUT, I think 2k5 still has BCP and the equivelent to "xp_CmdShell" (although I'm pretty sure they call it something else). If you call BCP via a CmdShell call and use the QueryOut setting, you can even name the file you want to save to with a little dynamic SQL. See if you can find "BCP" in Books Online... make sure you read about all the different settings you can have. And, yes, it does have a couple of simple examples. It's a VERY powerful tool. The separator you're looking for is \t which means "tab".

--Jeff Moden
  #5 (permalink)  
Old November 22nd, 2007, 01:49 AM
Registered User
 
Join Date: Nov 2007
Location: hyderabad, andhrapradesh, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How to configure sql server express stored procedures to execute xp_cmd shell.

want to use xp_cmdshell to save the result of a sqlserver expresss query to a text file.

Can any one help me out in this aspect.

Thanks & Regards
Anujahnavi S.


Quote:
quote:Originally posted by Jeff Moden
 I just realized this is a 2k5 forum, not 2k... I don't know how to use SSIS...

BUT, I think 2k5 still has BCP and the equivelent to "xp_CmdShell" (although I'm pretty sure they call it something else). If you call BCP via a CmdShell call and use the QueryOut setting, you can even name the file you want to save to with a little dynamic SQL. See if you can find "BCP" in Books Online... make sure you read about all the different settings you can have. And, yes, it does have a couple of simple examples. It's a VERY powerful tool. The separator you're looking for is \t which means "tab".

--Jeff Moden


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query output to XML using BCP HELP!! miamikk SQL Language 3 May 15th, 2009 08:22 AM
Sql query output to XML or HTML file miamikk SQL Language 4 June 6th, 2007 03:58 AM
How to output dataset to .txt file not to .xml? nesrine C# 1 March 8th, 2007 11:34 AM
Cannot display/return SQL Query Output from a Vari sjm SQL Server DTS 1 September 9th, 2005 11:40 AM
Disassembler (output on .txt file) gettipu J2EE 0 February 20th, 2005 03:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.