Semantics PPT file
Problem
Sometimes it is necessary to search for specific content inside documents stored in a SQL Server database. Is it possible to do this in SQL Server? Can I run T-SQL queries and find content inside Microsoft Word files? Yes, now with SQL Server 2012 you can do a semantic search. You can create a T-SQL query and look for information inside a Word document or other documents. In this tip, we will look at how this works.
Solution
SQL Server 2012 introduces a new search feature beyond the relational platform called semantic search. This feature extends the semantic full-text search capabilities to external files.
Installation
The Semantic Search engine can be installed when you do the initial installation of SQL Server or it can be added later.
Here is a screenshot of the option when you do a normal installation:
If you did not install this when you did the initial installation you can run the SQL Server installer for the SemanticLanguageDatabase as shown below. This can be found in the SQL Server setup folder.
Verify Features Are Installed
To verify if you have Full Text and Semantic Search installed you can run this query:
SELECT SERVERPROPERTY('IsFullTextInstalled')
The following query s used to verify that the semantic database is installed and registered:
SELECT * FROM sys.fulltext_semantic_language_statistics_database
Create Sample Database
To use this new feature we are going to use the FileTable feature in SQL Server 2012. First I am going to create a folder where we will store our database files. In this example I have created a folder called "C:\FileTable".
After this folder is created, open SQL Server Management Studio and create a new database called "FileSearchTest". This is created just like any other database except we are going to also enable FILESTREAM for this database as well.
The script below creates the database:
CREATE DATABASE FileSearchTest ON PRIMARY ( NAME = N'FileSearchTest', FILENAME = N'C:\FileTable\FileSearchTest.mdf' ), FILEGROUP FilestreamFG CONTAINS FILESTREAM ( NAME = MyFileStreamData, FILENAME= 'C:\FileTable\Data' ) LOG ON ( NAME = N'FileSearchTest_Log', FILENAME = N'C:\FileTable\FileSearchTest_log.ldf' ) WITH FILESTREAM ( NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'FileTable' )