Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

textcopy is not recognised as an internal or external command

Posted on 2006-05-23
7
Medium Priority
?
871 Views
Last Modified: 2012-06-21
Hi guys,

I am trying to create a batch routine to export some binary data from a table to files, but am having some problems.

Here is the code I've used:

CREATE PROCEDURE sp_textcopy (
  @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))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
         'textcopy /S ' + @srvname +
         ' /U ' + @login +
         ' /P ' + @password +
         ' /D ' + @dbname +
         ' /T ' + @tbname +
         ' /C ' + @colname +
         ' /W "' + @whereclause +
         '" /F ' + @filename +
         ' /' + @direction
EXEC master..xp_cmdshell @exec_str


DECLARE @File nvarchar(50)
DECLARE @FileX nvarchar(50)
DECLARE @FileY nvarchar(50)
DECLARE Cur Cursor FOR
SELECT Name FROM dbo.Attachments
OPEN Cur
FETCH NEXT FROM Cur INTO @File

WHILE @@FETCH_STATUS=0
BEGIN
      SELECT @FileX = 'c:\' + @File
      SELECT @FileY = ' WHERE NAME=`' + @File + '`'
      EXEC sp_textcopy @srvname = 'localhost',
            @login = '*********',
            @password = '*************',
            @dbname = 'BAA',
            @tbname = 'dbo.Attachments',
            @colname = 'Attachment',
            @filename = @FileX,
            @whereclause = @FileY,
            @direction = 'O'
      FETCH NEXT FROM Cur INTO @File
END


It runs fine, but I get this error:


'textcopy' is not recognized as an internal or external command,
operable program or batch file.
NULL



Any ideas what I am doing wrong?

Thanks!
0
Comment
Question by:Cyber-Drugs
  • 5
  • 2
7 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16742274
1.  you need to mention the path of the file
2.  or Copy that file into C:\
3.  Add a path command in Autoexec.Bat , which refers to the folder on which TextCopy.exe
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 16742327
SELECT @exec_str = 'c:\Progra~1\Micros~1\MSSQL\Binn\textcopy.exe /S' +@srvname +
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16742374
or simply copy that file to C:\
and use like
C:\textCopy /S
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 16743948
OK, that runs now, but now it's giving me an error about my WHERE clause...

TEXTCOPY Version 1.0
DB-Library version 8.00.194
SQL Server 'RAPIER-SERVER' Message 170: Line 1: Incorrect syntax near '`'. (Concerning line 1)
DB-Library Error 10007: General SQL Server error: Check messages from the SQL Server.
ERROR: Query execution failed.
NULL



I am using:

SELECT @FileY = ' WHERE NAME=`' + @File + '`'

because this didn't work:

SELECT @FileY = " WHERE NAME='" + @File + "'"


What can I use that will work?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16744004
replace that special character with '

SELECT @FileY = ' WHERE NAME='' + @File + '''
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 16744072
Ah, I was under the impression that wouldn't work, as it's the same quotes, but it works beautifully.

Thanks again aneeshattingal !! :)
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16744113
Actually it was because you copied from the webpage ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question