SQL Server 2008 allows us to store XML, emails, files and spatial information. FileStream is a new datatype introduced in Katmai, its used to stored the data in the file system.
Details about the file like file type, file size, file name will be considered as structured data and its stored in the sql server database whereas the contents of the file is considered as an unstructured data and gets stored in the file system. The contents can be accessed either by Win32 API or by using T-SQL statements.
Steps to be followed in implementing File Stream Data type:
1. First, we have to configure the file stream property.
Belows is the syntax to configure the file stream property,
Code Snippet |
sp_filestream_configure [ [ @enable_level = ] level ] [ [ , @share_name = ] 'share_name' ] |
The enable level should have a value from 0 to 3 indicating the authorization level like whether T-SQL access is allowed or not, Win32 API is required or not etc..,
2. Once executing the above command just check it out in the command prompt using the command NET SHARE.
3. The primary requirement to implement file stream property is to create the database with atleast one filegroup contains filestream property.
4. Create the table with column type as filestream. Unique constraint will be enforced on the table which has filestream type.
5. Insert the data into file stream datatype column and it gets stored in the file system.
Please provide me your valuable feedback. I will post the exact code in my next postings.
Regards,
Venkatesan Prabu .J
2 comments:
can you show with an example...like how you store say a pdf or image file or an XML data as file stream input and corresponding retrieval..it will be great help!
Hi, here its been said that we can use T-SQL stmts to access the contents of the file. Say i store a text file and want to search for a particular word in that file. Is this possible? i would be very helpful if could provide one example
Post a Comment