Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
derach2000
Starting Member
37 Posts |
Posted - 2012-07-26 : 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 returnthe file to disk using sql.Help, anyoneKind regardsArmin Mahmutovicstudent of Clarion,C#,Crystal and SQL martial arts |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-07-26 : 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
15732 Posts |
Posted - 2012-07-26 : 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
37 Posts |
Posted - 2012-07-26 : 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 replaysKind regardsArmin Mahmutovicstudent of Clarion,C#,Crystal and SQL martial arts |
 |
|
|
|
|
|