Textcopy.exe in TSQL

Last Post 09 Dec 2007 07:03 AM by valajbeg. 7 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
LostFromTheStart
New Member
New Member

--
02 Nov 2005 10:00 AM
Hi All,

I am trying to write a SP using TEXTCOPY. I am getting an error. To help debug the proc I have reduced it to the following code

DECLARE @exec_str varchar (255)
SELECT @exec_str = 'G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe -?'
EXEC master..xp_cmdshell @exec_str

When I try to run this I get the following error

'G:\Program' is not recognized as an internal or external command, operable program or batch file.

Does anybody know how to get this to work?


even tried
exec master.dbo.xp_cmdshell "G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe -?" and
exec master.dbo.xp_cmdshell 'G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe -?' and
get 'G:\Program' is not recognized as an internal or external command, operable program or batch file.
nosepicker
New Member
New Member

--
02 Nov 2005 03:08 PM
Put double quotes around the path (otherwise the command line interprets a space as a break between commands):

SELECT @exec_str = '"G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe" -?'
LostFromTheStart
New Member
New Member

--
16 Nov 2005 11:34 AM
Hi Guys,

Can anybody help with this error.... I tried the " but it didn't seem to help in this case. I think the problem is with the where clause.

SAMPLE CODE
declare @srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1)

DECLARE @exec_str varchar (255)
--SELECT @exec_str = 'C:\A_Temp\B_temp\textcopy.exe' +
--SELECT @exec_str = 'C:\DocPool\service\textcopy.exe' +
set @srvname = 'DUNSQLD03'
set @login = 'DocPoolAdmin'
set @password = 'DocP00lAdm1N'
set @dbname = 'DocumentPool'
set @tbname = 'dbo.Files'
set @colname = '[File]'
set @filename = 'G:\DocPool\test.txt'
set @whereclause = '"where fileId = 1"'
set @direction = 'I'
select @exec_str = '"G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe" ' +
' /S ' + @srvname +
' /U ' + @login +
' /P ' + @password +
' /D ' + @dbname +
' /T ' + @tbname +
' /C ' + @colname +
' /W ' + @whereclause +
' /F ' + @filename +
' /' + @direction
--DECLARE @exec_str varchar (255)
--select @exec_str = '"G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe" -?'
--SELECT @exec_str = 'G:\DocPool\service\textcopy.exe -?'
print @exec_str
EXEC master..xp_cmdshell @exec_str


OUTPUT of string

"G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe" /S DUNSQLD03 /U DocPoolAdmin /P DocP00lAdm1N /D DocumentPool /T dbo.Files /C [File] /W "where fileId = 1" /F G:\DocPool\test.txt /I

ERROR MESSAGE
'G:\Program' is not recognized as an internal or external command, operable program or batch file.
NULL
bnadagouda
New Member
New Member

--
22 Sep 2006 09:54 AM
Here is what you need to do put double quotes around program files after G:
so
output string should be G:\"program files"\"Microsoft sql server"\mssql\ ...
Other option is just copy the TEXTCOPY.exe to some place like c:\temp folder. Ensure that there is no space in the folder name and use it in your string generation.
It will work
valajbeg
New Member
New Member

--
09 Dec 2007 07:03 AM
that trick with path just gives you:

ERROR: Argument 'Files"Microsoft SQL Server\MSSQL\Binn\textcopy.exe' not recognized

do you have some other idea?

p.s. tha trick with moving textcopy to certain location is working ok...
tkennedy
New Member
New Member

--
06 Feb 2008 09:47 AM
SELECT @exec_str = '"d:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe" -?'
SQLUSA
New Member
New Member

--
07 Feb 2008 12:21 AM
"G:\Program Files\Microsoft SQL Server\MSSQL\Binn\textcopy.exe"

You don't need the double quote.

Here is an example: http://www.sqlusa.com/bestpractices...ackupfile/


Kalman Toth - Database, Data Warehouse & Business Intelligence Architect
SQLUSA: http://www.sqlusa.com/access2007/ The Best SQL Server 2005 Training in the World!
SQLUSA
New Member
New Member

--
07 Feb 2008 03:22 PM
Yes Russell! Thanks for clarifying.

It makes sense!!!

The old DOS (MS-DOS, etc.)....

We should be happy that it works with double quotes.


Kalman Toth - Database, Data Warehouse & Business Intelligence Architect
SQLUSA: http://www.sqlusa.com/order2005grandslam/ The Best SQL Server 2005 Training in the World!




You are not authorized to post a reply.

Acceptable Use Policy