sql - BCP Utility Not returning/Hangs -


i creating simple stored procedure export output of query text file using bcp shown below.

when execute sp sql management sudio, results pane sits there "executing query..." doesn't return error nor come back.

any appreciated..i have spend lot of time on already.

create procedure sptestshell execute 'cmdshell' begin      declare @command varchar(512)      set @command = 'bcp "select * dbname.dbo.[importfiletable]" queryout "c:\bcptest.txt" -t -c -s' + @@servername      print @command       exec xp_cmdshell @command  end  exec sptestshell  

the fact 'hangs', suggests me process trying to, cannot connect server.

i think problem there no space between -s parameter , server name. won't able connect server name invalid. try adding space see if fixes it, i.e.

set @command = 'bcp "select * dbname.dbo.[importfiletable]" queryout "c:\bcptest.txt" -t -c -s ' + @@servername 

if doesn't work, perhaps put [] brackets round server name, name might causing problems.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -