SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 FILESTREAM
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

derach2000
Starting Member

Bosnia and Herzegovina
35 Posts

Posted - 07/26/2012 :  09:07:34  Show Profile  Reply with Quote
Hi,

I'v managed to insert data using FILESTREAM and OPENROWSET.

Now, I'm stuck. Can't seem to find a way to return
the file to disk using sql.

Help, anyone

Kind regards

Armin Mahmutovic
student of Clarion,C#,Crystal and SQL martial arts

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 07/26/2012 :  09:26:54  Show Profile  Reply with Quote
My experience with filestream is limited to reading articles about it and imagining how nice it would be to have an opportunity to use it. But, from what I can tell, usually you don't access the files using T-SQL. Client code such as a .Net program is used to access it.

See Jacob Sebastian's article on simple-talk, which is simple and well-written. In particular, look at the section "Accessing FILESTREAM Data using TSQL". http://www.simple-talk.com/sql/learn-sql-server/an-introduction-to-sql-server-filestream/
Go to Top of Page

robvolk
Most Valuable Yak

USA
15559 Posts

Posted - 07/26/2012 :  09:35:38  Show Profile  Visit robvolk's Homepage  Reply with Quote
My question for you would be why put it in the database at all if you want to access it as a file? Just leave it as a file and insert the filename and path in the database.
Go to Top of Page

derach2000
Starting Member

Bosnia and Herzegovina
35 Posts

Posted - 07/26/2012 :  10:26:01  Show Profile  Reply with Quote
Found a solution using bcp and format file.

DECLARE @sql varchar(8000);

select @sql = 'bcp "SELECT VARBINCOLUMN FROM DB.dbo.TABLE WHERE COLUMNID= 1" queryout d:\somefile.txt -S service -T -fd:\f.fmt';

exec master..xp_cmdshell @sql;

FMT file:

9.0
1
1 SQLBINARY 0 0 "" 1 Doc ""

Filestream is better because server controls the files on hard drive.
Now it needs some testing.

Thanks for the replays

Kind regards

Armin Mahmutovic
student of Clarion,C#,Crystal and SQL martial arts
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000