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.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 FileStream Missing files

Author  Topic 

123sqlteam
Starting Member

4 Posts

Posted - 2011-08-18 : 14:54:52
MSDN states Creating a Data File
The following example shows how to use INSERT to create a file that contains data. The Database Engine converts the string Seismic Data to a varbinary(max) value. FILESTREAM creates the Windows file if it does not already exist.The data is then added to the data file.

FileStream is enabled and tested. Have $FSLOG and filestream.hdr.
Inserts work fine for the filestream enabled table.

re: http://www.sqlskills.com/blogs/paul/category/filestream.aspx
INSERT INTO FileStreamTest1 VALUES (
NEWID (), 'Paul Randal',
CAST ('SQLskills.com' AS VARBINARY(MAX)));
GO

I should see a new folder with guid name in which my binary blob is sitting. Blob file never gets created and I have no errors, event logs, everyone ACL/modify on this folder.

What am I missing. A collegue suggested using c# to achive this,
1 - get file path from sproc after insertion and write to ntfs

... code omitted ...
SqlParameter SqlParamOutput = new SqlParameter("@filepath", System.Data.SqlDbType.VarChar, -1);
SqlParamOutput.Direction = System.Data.ParameterDirection.Output;

SqlCmd.Parameters.Add(SqlParam2);
SqlCmd.Parameters.Add(SqlParam1);
SqlCmd.Parameters.Add(SqlParamOutput);

SqlCmd.ExecuteNonQuery();

string Path = SqlCmd.Parameters["@filepath"].Value.ToString();

SqlCmd = new SqlCommand("SELECT GET_FILESTREAM_TRANSACTION_CONTEXT()", SqlCon, SqlTran);

byte[] objContext = (byte[])SqlCmd.ExecuteScalar();


System.Data.SqlTypes.SqlFileStream SqlFileStream = new System.Data.SqlTypes.SqlFileStream(Path, objContext, System.IO.FileAccess.Write);

SqlFileStream.Write(buffer, 0, buffer.Length);
SqlFileStream.Close();

This seems to defeat the purpose of filestream.

Thanks.

123sqlteam
Starting Member

4 Posts

Posted - 2011-08-19 : 14:02:20
RESOLUTION by Bob
http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/d147fe11-ccad-41e0-8367-81075c2ca555
Go to Top of Page
   

- Advertisement -