FileStream Part-3

You can access first two parts from here

Part-1
Part-2

Lets see now  how to use FileStream to access files.




USE FileTest

CREATE TABLE FileTestTable  AS FILETABLE


This will create table with necessary fileds for file properties

Lets see the structure of this table




Next step will be to copy files to the shared location and access it using this table

  • We will go to windows share which we configured in part-1 for Server at location \\Server\MSSQLSERVER

  • Here we will get Directory which we configured for database in part-2 


  • Here we will get directory for the table which we created

  • Copy files this location    \\server\MSSQLSERVER\FileTableExampleDir\FileTestTable
   We will copy a file here



Now query the table



SELECT *
FROM   FileTestTable




As we can see we get details for the files from the table

Ok If we delete the record from table what will happen?
It will delete file from that  location also.

So it means we can manage windows files by the table in SQL Server itself :-)



  



No comments:

Post a Comment

Popular Posts