Wrox Programmer Forums
|
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 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
 
Old March 29th, 2012, 11:11 AM
Friend of Wrox
 
Join Date: Oct 2006
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
 
Old March 29th, 2012, 02:02 PM
Friend of Wrox
 
Join Date: Oct 2006
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





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 11:00 AM
Securing xp_cmdshell Steve_tucker SQL Server 2000 1 December 8th, 2004 06:44 PM
xp_cmdshell Steve_tucker SQL Server 2000 3 November 22nd, 2004 04:15 PM
Executing xp_cmdShell Hari_Word SQL Server 2000 1 August 13th, 2004 03:35 PM





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