Hi Stuart,

 

Take a look at the ADO.NET samples here for reading varbinary(max) columns:
<http://msdn.microsoft.com/en-us/library/bb399384.aspx>
http://msdn.microsoft.com/en-us/library/bb399384.aspx (in particular,
GetSqlBinary and GetBytes).

 

Regards,

 

Greg

 

Dr Greg Low

 

1300SQLSQL (1300 775 775) office | +61 419201410 mobile│ +61 3 8676 4913 fax


SQL Down Under | Web:  <http://www.sqldownunder.com/> www.sqldownunder.com

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Stuart Kinnear
Sent: Sunday, 13 May 2012 11:19 AM
To: ozDotNet
Subject: Re: Selecting data stored using FileStream in SQl Server

 

You can get stuff in very easily using the plethora of examples, however
using T-SQL to get the record out is not possible, perhaps because of the
need to isolate the field value and deal with it separately. If you were to
create a clr function using the info available for c# code then you would
have means to do it via SQL server.

 

I played with the idea of using bcp, but it corrupted the binary. Perhaps as
bcp expects a tabulated output it adds termination values to the file .


eg.

declare @sql varchar(8000)

select @sql = 'bcp "SELECT TOP 1 blob FROM mydatabase.dbo.Myblob" queryout
c:\Temp\Mydump.txt -n -T -S MyServer\MyInstance'

exec master.. xp_cmdshell @sql 

 

this might work for you if the records were plain text.

 

 

Regards, Stuart

 

 

 

On 12 May 2012 23:33, Peter Maddin <petermad...@iinet.net.au> wrote:

I have found examples of how to use T-SQL to insert a file as a Filestream
blob in SQL Server 2008.

 

I have not been successful at finding out how to use just T-SQL to select
the same blob data to a local file.

All the examples I have seen are code based (C# etc.). Is it possible just
to use T-SQL to persist a FileStream blob to a local file?

 

Regards Peter Maddin

 

 





 

-- 
----------------------------------------------------------------------------
-
Stuart Kinnear
Mobile: 040 704 5686.   Office: 03 9589 6502

SK Pro-Active! Pty Ltd
acn. 81 072 778 262
PO Box 6117 Cromer, Vic 3193. Australia

Business software developers.
SQL Server, Visual Basic, C# , Asp.Net, Microsoft Office.
----------------------------------------------------------------------------
-

Reply via email to