|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 11:19 AM
Points: 50,
Visits: 108
|
|
DECLARE @Cmd VarChar(4000) DECLARE @SProcName VarChar(40) DECLARE @SP_Parm1Value VarChar(40) DECLARE @SP_Parm2Value VarChar(4000)
set @SProcName = 'Rpt_JobTransactionsSp' set @SP_Parm2Value = '|SRMQDIC|,|ROD|,|B|,|HNS|,|0|,|B|,null,null,null,null,|000|,|9999|,|1/1/2013|,|3/17/2013|,null,null,null,null,null,null,null,null,|T|,null,null,|1|,|0|,|1033|' set @SP_Parm2Value = REPLACE (@SP_Parm2Value,'|', '''')
-- Build BCP Command set @CMD = '' Set @Cmd = @Cmd + 'bcp "exec ' + db_name() Set @Cmd = @Cmd + '..' + @SProcName + ' ' Set @Cmd = @Cmd + @SP_Parm2Value + '"'
Set @Cmd = @Cmd + ' Queryout ' + ' "c:\temp\query.txt" ' + ' -T -c -t^| -S '+ @@servername SELECT @Cmd --output looks like this bcp "exec RSDV_App..Rpt_JobTransactionsSp 'SRMQDIC','ROD','B','HNS','0','B',null,null,null,null,'000','9999','1/1/2013','3/17/2013',null,null,null,null,null,null,null,null,'T',null,null,'1','0','1033'" Queryout "c:\temp\query.txt" -T -c -t^|
The following statement works great and gives me desired data in the grid. exec RSDV_App..Rpt_JobTransactionsSp 'SRMQDIC','ROD','B','HNS','0','B',null,null,null,null,'000','9999','1/1/2013','3/17/2013',null,null,null,null,null,null,null,null,'T',null,null,'1','0','1033'
But when i execute the follwing command EXEC master..xp_cmdshell @cmd
Errors out output --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQLState = 37000, NativeError = 2812 Error = [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.EXTGEN_InitSessionContextSp'. NULL
There is a prcedure 'dbo.EXTGEN_InitSessionContextSp' running inside 'Rpt_JobTransactionsSp'.
Whats the workaround for this ?
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 6:59 PM
Points: 4,557,
Visits: 8,215
|
|
| Which server you want your bcp to connect to?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:27 PM
Points: 6,735,
Visits: 11,788
|
|
Are you sure that is the entire output? I see you are appending -S but it is not in the comment where you say "output looks like this"
bcp "exec RSDV_App..Rpt_JobTransactionsSp 'SRMQDIC','ROD','B','HNS','0','B',null,null,null,null,'000','9999','1/1/2013','3/17/2013',null,null,null,null,null,null,null,null,'T',null,null,'1','0','1033'" Queryout "c:\temp\query.txt" -T -c -t^|
Make sure that SSMS is set to return more all the characters, see Tools > Options > Query Results > Results to Text/Grid.
Try taking the [complete] command line output from your code and execute it at a cmd shell prompt, i.e. let's take xp_cmdshell out of the equation for a minute to see if it is part of the issue, or whether we see an issue just using bcp. I think I know what's going on, but please post the results.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 11:19 AM
Points: 50,
Visits: 108
|
|
I am running the code from the SQL Server Management Studio. Do i need to specify the Server name , user name and password ?
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 11:19 AM
Points: 50,
Visits: 108
|
|
| Yes In the code i am appending the Servername but i get same result with or without the ServerName.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:27 PM
Points: 6,735,
Visits: 11,788
|
|
skb 44459 (3/21/2013) I am running the code from the SQL Server Management Studio. Do i need to specify the Server name , user name and password ? I do not think you do. -T means to use Windows Auth so you only need one or the other.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:27 PM
Points: 6,735,
Visits: 11,788
|
|
skb 44459 (3/21/2013) Yes In the code i am appending the Servername but i get same result with or without the ServerName. Have you modified SSMS so you can see the entire output showing what xp_cmdshell would run? i.e. the entire contents of the variable?
WHen you can, copy the bcp command line and run it directly from a cmd shell prompt. Let us know the output.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 11:19 AM
Points: 50,
Visits: 108
|
|
Here is the command and output. FYI: 'dbo.EXTGEN_InitSessionContextSp' is getting called from Rpt_JobTransactionsSp
bcp "exec PHIL_App..Rpt_JobTransactionsSp 'SRMQDIC','ROD','B','HNS','0','B', null,null,null,null,'000','9999','1/1/2013','3/17/2013',null,null,null,null,null ,null,null,null,'T',null,null,'1','0','1033'" Queryout "c:\temp\query.txt" -T -c -t^| -Sphlsqlsl01 SQLState = 37000, NativeError = 2812 Error = [Microsoft][SQL Native Client][SQL Server]Could not find stored procedur e 'dbo.EXTGEN_InitSessionContextSp'.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:27 PM
Points: 6,735,
Visits: 11,788
|
|
And just to confirm, when you run this in SSMS what does it do?
exec PHIL_App..Rpt_JobTransactionsSp 'SRMQDIC','ROD','B','HNS','0','B',null,null,null,null,'000','9999','1/1/2013','3/17/2013',null,null,null,null,null,null,null,null,'T',null,null,'1','0','1033'
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: 2 days ago @ 11:19 AM
Points: 50,
Visits: 108
|
|
i get the desired output.
(1 row(s) affected)
(0 row(s) affected)
(1 row(s) affected)
(12932 row(s) affected)
then all the records are displayed.
|
|
|
|