Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Microsoft SQL Server 2008 Programming
This is the forum to discuss the Wrox book Professional Microsoft SQL Server 2008 Programming by Robert Vieira; ISBN: 9780470257029
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Microsoft SQL Server 2008 Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 29th, 2012, 11:11 AM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , , .
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts
Default xp_cmdshell HELP...

Hi all,

1st question is in a store procedure exec xp_cmdShell can i call another store procedure.

if so why doesn"t it like when i pass it variables... i thought of doing this because select statement is long...

by doing a simple select * from tablename the file gets created with the info so that works fine...

thanking you in advance

Rino

...
alterPROCEDURE [dbo].[sp_CreateTextFile]
@intSCate1 int,
@intSCate2 int,
@intvendor int
AS
BEGIN
SETNOCOUNTON;
Exec DBName..xp_cmdshell 'bcp "'exec sp_AutoReplenishment' + @intSCate1 + ',' +@intSCate2+ ',' + @intvendor" queryout "C:\PO.csv" -T -c -t,'

END


Last edited by RinoDM; March 29th, 2012 at 11:25 AM. Reason: mis
  #2 (permalink)  
Old March 29th, 2012, 02:02 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , , .
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Got it to work...

DECLARE @FileName varchar(50),
@bcpCommand varchar(3000)
SET @FileName =REPLACE('c:\PO_'+CONVERT(char(8),GETDATE(),1)+'.csv','/','-')
SET @bcpCommand ='bcp "exec sp_AutoReplenishment '
SET @bcpCommand = @bcpCommand + @intSCate1 +','+@intSCate2+','+ @intvendor +'" queryout '
SET @bcpCommand = @bcpCommand +'"'+@FileName +'" -T -c -t,'
Exec DBName..xp_cmdshell@bcpCommand
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with xp_cmdshell ninel SQL Server 2000 1 August 26th, 2006 09:39 AM
xp_cmdshell help needed. Clauddvon SQL Server 2000 2 March 1st, 2006 10:00 AM
Securing xp_cmdshell Steve_tucker SQL Server 2000 1 December 8th, 2004 05:44 PM
xp_cmdshell Steve_tucker SQL Server 2000 3 November 22nd, 2004 03:15 PM
Executing xp_cmdShell Hari_Word SQL Server 2000 1 August 13th, 2004 03:35 PM



All times are GMT -4. The time now is 07:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.