SQL Server 2008 Image to File (textcopy.exe)

Hi everyone,
    I currently have a SQL Server 2000 database and we are storing small graphics in the database.  No problem getting them in, we use an ADO stream.  Very fast!!  No worries there.  We use TextCopy.exe to move the images to a file and then email.  No worries there either.

    Now I'm working on a SQL Server 2008 database and I can stream the images to the database all day long, but I can't find the TextCopy command anywhere in the install.  Did they remove it from 2008?  Is there a better way to take am graphic from an image field and put it to file?
    I've been searching the web and EE and seem to be hitting a dead end.  Can someone please point me in the right direction?

Thanks,
Mike
LVL 18
Data-ManCOOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eugene ZCommented:
TextCopy.exe is gone in sql 2005-2008
-----
however you can try to use textcopy.exe in SQL 2008:
copy it to sql server 2008 from 2000 and try to run it e.g. from xp_cmdshell
 --
also
try solution from
http://www.eggheadcafe.com/forumarchives/SQLServerserver/Jan2006/post26065778.asp 
SELECT BlobData.*  
 
FROM OPENROWSET  
 
(BULK ''' + @FileName + ''',  
 
SINGLE_BLOB)
--
 
more
http://msdn.microsoft.com/en-us/library/ms190312.aspx 
0
Eugene ZCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Data-ManCOOAuthor Commented:
Eugene,
     I appreciate all the links, but I've seen them before.  Here is what I used to have in 2000.

SELECT @strExec = 'C:\Progra~1\Micros~1\MSSQL\Binn\textcopy.exe /S /U ' + SYSTEM_USER
SELECT @strExec = @strExec + ' /P ' + @strPW + ' /D Balance_StRegis_NYC /T tblApplicationComments /C ScreenImage '
SELECT @strExec = @strExec + '/W "WHERE ApplicationCommentID=' + @strID + '" /F ' + @strLocalFileName + ' /O'
                        
EXEC master..xp_cmdshell @strExec

This little snippet of code would take one image from a single record and write it to a file.  All the links you are showing me take me down a different path.  I do not program in any version of C.

I have to believe that there is a simple way via T-SQL to take the data in an image field and put it to a file in SQL Server 2008.

I can't be the only person in the world trying to do this.

Thanks,
Mike
0
Eugene ZCommented:
ok , you did not tell you need them out of DB
Did you try SSIS (like DTS)?
0
Eugene ZCommented:
please check
HOW TO: Read and Write a File to and from a BLOB Column by Using Chunking in ADO.NET and Visual Basic .NET
http://support.microsoft.com/kb/317034
---
Save and Display Images using ASP .NET 2.0 Profile
http://www.dotnet-friends.com/articles/asp/artinasp03e650de-2b15-4fb1-9bdb-aad1a1e5ac5c.aspx 
 
0
Data-ManCOOAuthor Commented:
Please reread my original post.

It says that I don't have any problems putting the graphics in the SQL Server database.

The question I asked was.....Is there a better way to take a graphic from an image field and put it to file?

I do not want to stream the image back to the client and do something with it there.  I need to put the image to a local file on the server (which is why I was using TextCopy).  Once it's local then I can use dbmail to send an email with the graphic as an attachment.

Hope this helps

Thanks,
Mike
0
Eugene ZCommented:
check my last posted links
0
Data-ManCOOAuthor Commented:
I am looking for a solution that runs on the SQL Server Box...preferrably a T-SQL Solution.

Mike



0
Anthony PerkinsCommented:
>>preferrably a T-SQL Solution<<
You are out of luck.  There is no T-SQL only solution (and never has been)
0
Data-ManCOOAuthor Commented:
acperkins,
It's been a couple of years, but I think you've answered a question or two of mine in the past and I'm sure I've used a solution or two that you have posted.  :-)

TextCopy worked great.  Used it for years.  The command was executed in a command shell, but was still accomplished by executing a proc.

There isn't a workaround in 2008 for the removal of the textcopy command?

Is there another solution to populating the attachment with a graphic contained within the image data type without sending it down to the client?

I have to believe that there has to be a way to take the data in an image field and write it to a file (at the server).


Thanks,
Mike
0
Anthony PerkinsCommented:
>>TextCopy worked great. <<
I know exactly what is TextCopy, it is a utility built for exactly the purpose you need and I have actually used it about 10 years ago.  But it is not T-SQL.  

>>The command was executed in a command shell, but was still accomplished by executing a proc. <<
So does Notepad.  That does not qualify it as T-SQL.

>>There isn't a workaround in 2008 for the removal of the textcopy command?<<
Did you not see the comment http:a24747424 ?

>>Is there another solution to populating the attachment with a graphic contained within the image data type without sending it down to the client?<<
Not without writing an app to do it and install on the server.

>>I have to believe that there has to be a way to take the data in an image field and write it to a file (at the server).<<
See above.

>>I can't be the only person in the world trying to do this.<<
In general it is not considered good practice to store images in the database, that is why there has never been much demand for it.  Having said that, MS SQL Server has introduced a new attribute called FILESTREAM that makes the process somewhat more palatable.
0
Anthony PerkinsCommented:
>>It's been a couple of years, but I think you've answered a question or two of mine in the past and I'm sure I've used a solution or two that you have posted. <<
And if you look carefully you will actually find VB6 solutions using ADO that I have posted for reading and writing image data to the database.  I realize this is not what you need and instead are looking for an ellusive T-SQL solution, however I mention this so that you are aware that I know exactly what you are after.
0
Data-ManCOOAuthor Commented:
I was looking for a work around solution that could be run via a stored procedure.  After a day of searching, building and testing I was able to create a working solution.  The final solution use the stored procedure xp_cmdShell to execute an SSIS package, but it does not employ the TextCopy command.  And a xp_cmdShell is still available in SQL Server 2008 the solution is viable.

After clicking on the SSIS link to Microsoft and seeing the Export Column Transformation capabilities, it pointed me in the right direction. I scoured the web for examples and found one that really helped.

How to create an Export Column Transformation SSIS package
http://books.google.com/books?id=i4gg8AqZHMoC&pg=PA159&lpg=PA159&dq=create+%22export+column%22+ssis+package&source=bl&ots=B0hes5TRel&sig=4m2DOxfs4pgzojULZ2Y8ZEGBqqc&hl=en&ei=h2ZPSoXqJ4LwsQPNm_nWBQ&sa=X&oi=book_result&ct=result&resnum=10

The above link was probably the most helpful, but also required a lot of other research.  I have never created an SSIS package before so there were a number of steps that required multiple Google searches to determine how to accomplish said step.

How to execute an SSIS package with variables via T-SQL.
http://www.codeproject.com/KB/database/Call_SSIS_from_SP.aspx

Found out that variables within the SSIS are case sensitive.
http://sqlblogcasts.com/blogs/simons/archive/2007/07/23/SSIS---Variable-lists-for-the-script-task-are-case-sensitive.aspx

I normally dont worry whether or not my not my variables are case sensitive.  Since I follow strict naming conventions, my variables are always referenced the same as they are declared.  

And finally with a couple of hours of trouble shooting I found out that not only the variables must be case sensitive, but so is the word Value, it must start with an upper case V.  Which is interesting because it makes no difference if the word SET is upper or lower, it still works.

'/SET \package.variables[User::ID].value;"\"' + @strID + '\""

Is not the same as

'/SET \package.variables[User::ID].Value;"\"' + @strID + '\""

Notice the second one has an upper case V for value.  It will NOT work with a lower case v.

If you are looking for a workaround to the TextCopy command to move a file from your database to a local file, the above links should help you create a solution.

Happy coding!!

Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.