February 16, 2010 at 6:39 am
Hi all,
I have used following commands to make my DB capable of tackling Filestream.
ALTER DATABASE ThisTest ADD
FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM;
GO
ALTER DATABASE ThisTest ADD FILE (
NAME = FSGroup1File,
FILENAME = 'D:\sql\FSDATA')
TO FILEGROUP FileStreamGroup1;
GO
USE ThisTest;
GO
CREATE TABLE DocumentStore (
DocumentID INT IDENTITY PRIMARY KEY,
Document VARBINARY (MAX) FILESTREAM NULL,
DocGUID UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL
UNIQUE DEFAULT NEWID ())
FILESTREAM_ON FileStreamGroup1;
GO
But now how should I insert the data in this table? I have five pics (each 600 KB).
October 15, 2010 at 8:51 am
Can someone please explain how i can add a bob object like a word document etc in the sql server 2008 db.
I am not able to understand how exactly a file etc can be saved in the db. If for eg i have a file stored on my local sql server C:\Myfolder\Myfile.doc how exactly can i save this in the db using managment studio tsql query.
thanks in advance.
October 18, 2010 at 2:38 am
Hi,
Take a look at this link:
It's a brilliant explanation on how to implement a simple filestream application. I created a WPF application, instead of ASP.NET. But I found the author's descriptions on how to read and write FileStream data highly useful!
I hope this point you in the right direction:-)
October 18, 2010 at 10:43 pm
Thanks for the link but it explains using ado.net, is there a way i can insert data using the managment studio.
I really do not use ado.net
thanks for your time
October 19, 2010 at 12:57 am
I'm really not an expert on this, but shouldn't it in some way be possible to use the code in the stored procedure directly?
That is, create/adapt your own T-SQL script based on the code from the link.
I haven't tried it myself, but with a little time and adaptation I think you should get it to work.
Good luck!
March 12, 2012 at 8:22 pm
Well you could use this article, but I don't think that's what you need
or use a simple query using "OPENROWSET"
assume that you have a a table with 2 columns..
CREATE TABLE [dbo].[Images](
[ID] uniqueidentifier NOT NULL ROWGUIDCOL PRIMARY KEY,
[Image] [varbinary](max) filestream default NULL
) ON [PRIMARY]
you would insert using...
INSERT INTO [FStream].[dbo].[Images]
([ID],[Image])
VALUES
(NEWID(),
(SELECT * FROM OPENROWSET
(BULK 'C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\1.jpg',
SINGLE_BLOB) AS [Image]))
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply