| Author |
Topic  |
|
|
derach2000
Starting Member
Bosnia and Herzegovina
35 Posts |
Posted - 07/26/2012 : 09:07:34
|
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
|
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/ |
 |
|
|
robvolk
Most Valuable Yak
USA
15559 Posts |
Posted - 07/26/2012 : 09:35:38
|
| 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. |
 |
|
|
derach2000
Starting Member
Bosnia and Herzegovina
35 Posts |
Posted - 07/26/2012 : 10:26:01
|
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 |
 |
|
| |
Topic  |
|