| Author |
Topic |
|
nut
Starting Member
8 Posts |
Posted - 2012-03-21 : 09:14:24
|
| Any one help me please? What is wrongI use window2008 64bit and sql2008r2stdI have a problems when I run command in cmd mode(at server)my command is SET @command = 'bcp "select * from [dbInvoiceAX].dbo.InterfaceSaleOrder" queryout e:\data\temp\nut\bcptest.csv -c -S172.16.58.249 -Usa -P -fe:\data\temp\nut\ARAX1.xml'when run result is 'Command(s) completed successfully.'But No file , No output |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-21 : 09:24:38
|
| Sorry my full sp is CREATE PROCEDURE bcpaxtext ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.SET NOCOUNT OFF;DECLARE @command varchar(5000), @localPath varchar(80), @sqltext varchar(255)SET @localPath = '\\172.16.58.249\Data\Temp\nUT\' SET @sqltext = 'select * from [dbInvoiceAX].dbo.InterfaceSaleOrder'-- -S172.16.58.249 -Usa -P--SET @command = 'bcp "'+ @sqltext +'" queryout ' + @localPath + 'bcptest.csv' +'-c -T -f'+@localPath+'errorlog.log'+ ' -f'+@localPath+'ARAX1.xml'SET @command = 'bcp "select * from [dbInvoiceAX].dbo.InterfaceSaleOrder" queryout e:\data\temp\nut\bcptest.csv -c -S172.16.58.249 -Usa -P -fe:\data\temp\nut\ARAX1.xml'--EXEC master..xp_cmdshell @commandexec master..xp_cmdshell @commandENDGODrop PROCEDURE bcpaxtextGO |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-22 : 09:37:23
|
| Thank you Brett.Query out I just try.Yes, I run this SP on server. When I run This SP.msg is "Command(s) completed successfully."But no file create. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-22 : 10:43:04
|
| Dear Brett,e:\data\temp\nutThank. |
 |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-22 : 10:44:59
|
| Dear Bertt, I ready find "bcptest.csv" in my computer but not found. |
 |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-22 : 10:47:26
|
| But when I run 'bcp "select * from [dbInvoiceAX].dbo.InterfaceSaleOrder" queryout e:\data\temp\nut\bcptest.csv -c -S172.16.58.249 -Usa -P -fe:\data\temp\nut\ARAX1.xml'form command prompt. I can get file from this path "e:\data\temp\nut" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-23 : 04:46:53
|
| Yes Database is on same server.All my test csv file is on server E: Drivepath is e:\data\temp\nutI run at command prompt I can get file e:\data\temp\nut\bcptest.csvso, I deleteand run as procedure. I don't get any file. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nut
Starting Member
8 Posts |
Posted - 2012-03-23 : 09:26:10
|
| I try to run as your adviseSET NOCOUNT OFF;DECLARE @command varchar(5000), @localPath varchar(80), @sqltext varchar(255)SET @command = 'bcp [dbInvoiceAX].[dbo].[InterfaceSaleOrder] out e:\data\temp\nut\bcptest.csv -c -S172.16.58.249 -T'print @command--exec master..xp_cmdshell @commandGOresult is message=>bcp [dbInvoiceAX].[dbo].[InterfaceSaleOrder] out e:\data\temp\nut\bcptest.csv -c -S172.16.58.249 -TBut No file e:\data\temp\nut\bcptest.csv |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|