oledb - Full-text search using Windows Search Service and SQL Server 2008 R2 -
currently i'm trying query windows search service sql server 2008 r2 instance (also tested on sql server 2012) . windows search being exposed ole db datasource, giving me several options query search index. when configuring new linked server in sql server, management studio gives me option select microsoft ole db provider search, implying should able connect sql server. turns out challenge , running however. below you'll find error message stumbled upon.
ole db provider "search.collatordso" linked server "testserver" returned message "command not prepared.".
msg 7399, level 16, state 1, line 2
ole db provider "search.collatordso" linked server "testserver" reported error. command not prepared.
msg 7350, level 16, state 2, line 2
cannot column information ole db provider "search.collatordso" linked server "testserver".
things more interesting. although linked server solution isn't working, i'm able wrap code queries windows search in clr function (using msdn: querying index programmatically) , use if successfully within sql server. less desirable, because of steps needed set (deploying library, configuring permissions, etc.). i've tried several parameter settings, without luck. i've tried enabling of search.collatordso provider options, allowing provider instantiated in-process server. i'm using settings below. security i'm using login's current security context.
- provider:
microsoft ole db provider search
- data source:
(local)
- provider string:
provider=search.collatordso.1;extended?properties="application=windows"
- location:
-
additionally need search network drives, can done using shared windows libraries?
i'm aware more people have been struggling problem on last few years. i'm wondering if has been able , running, or point me in right direction.
oledb works
normal ado/oledb components can query windows search service connection string:
provider=search.collatordso.1;extended properties="application=windows"
and example query:
select top 100000 "system.itemname", "system.itemnamedisplay", "system.itemtype", "system.itemtypetext", "system.search.entryid", "system.search.gathertime", "system.search.hitcount", "system.search.store", "system.itemurl", "system.filename", "system.fileextension", "system.itemfolderpathdisplay", "system.itempathdisplay", "system.datemodified", "system.contenttype", "system.applicationname", "system.kindtext", "system.parsingname", "system.sfgaoflags", "system.size", "system.thumbnailcacheid" "systemindex" contains(*,'"contoso*"',1033)
you can try query directly on sql server in sql server management studio attempting run:
select * openrowset( 'search.collatordso', 'application=windows', 'select top 100 "system.itemname", "system.filename" systemindex');
which gives errors:
ole db provider "search.collatordso" linked server "(null)" returned message "command not prepared.". msg 7399, level 16, state 1, line 1 ole db provider "search.collatordso" linked server "(null)" reported error. command not prepared. msg 7350, level 16, state 2, line 1 cannot column information ole db provider "search.collatordso" linked server "(null)".
bonus reading
- connect windows search sql server using linked server (january 2011)
- link sql server (may 2008 - december 2012)
- trying access windows search sql server: appeal (july 2007)
- calling windows search sql server 2008 (march 2011)
- ole db provider "search.collatordso" returns "command not prepared" (april 2014 - suggests clr workaround)
- linked server windows search (february 2011)
- msdn blogs: query systemindex read microsoft search results fails when using search.collatordso provider (august 2009 - suggests clr workaround)
- vista search (february 2007)
have @ code..it may use [yourdb] go set ansi_nulls on go set quoted_identifier on go create proc [dbo].[searchalltables] @searchstr nvarchar(100) begin declare @dml nvarchar(max) = n'' if object_id('tempdb.dbo.#results') not null drop table dbo.#results create table dbo.#results ([tablename] nvarchar(100), [columnname] nvarchar(100), [value] nvarchar(max)) select @dml += ' select ''' + s.name + '.' + t.name + ''' [tablename], ''' + c.name + ''' [columnname], cast(' + quotename(c.name) + ' nvarchar(max)) [value] ' + quotename(s.name) + '.' + quotename(t.name) + ' (nolock) cast(' + quotename(c.name) + ' nvarchar(max)) ' + '''%' + @searchstr + '%''' sys.schemas s join sys.tables t on s.schema_id = t.schema_id join sys.columns c on t.object_id = c.object_id join sys.types ty on c.system_type_id = ty.system_type_id , c .user_type_id = ty .user_type_id t.is_ms_shipped = 0 , ty.name not in ('timestamp', 'image', 'sql_variant') insert dbo.#results exec sp_executesql @dml select * dbo.#results end
Comments
Post a Comment