Important alert: (current site time 7/15/2013 7:42:14 PM EDT)
 

VB icon

Indexing Service Query

Email
Submitted on: 5/18/2004 4:22:10 PM
By: JaCat  
Level: Intermediate
User Rating: By 1 Users
Compatibility: SQL Server 2000
Views: 10839
 
     Allows you to search within documents stored and indexed on disk.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
--**************************************
-- for :Indexing Service Query
--**************************************
(C) Treetop Technologies Inc.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
--**************************************
-- Name: Indexing Service Query
-- Description:Allows you to search within documents stored and indexed on disk.
-- By: JaCat
--
-- Inputs:query string in varchar type
--
-- Returns:table with path, filename
--
-- Assumes:how to setup Indexing service in Windows 2000 Server. Create an indexing service catalog.
--
--This code is copyrighted and has-- limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=840&lngWId=5--for details.--**************************************

/* BOL has an example of adding linked server */
sp_addlinkedserver FTIndexWeb, 'Index Server', 'MSIDXS', 'default'
go
/* Search MSDN for 'Default Property Names for a Web Catalog' to discover all the attributes
indexing server captures from documents in your folder
*/
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
/****** Object: Stored Procedure dbo.proc_searchScript Date: 5/18/2004 2:13:50 PM ******/
create procedure proc_search @querystring varchar(255)
/*
Object: proc_search
Description: returns varchar data based on input variables
Version: .0 beta 2004-4-27
*/
as
declare @tsql1 varchar(500), @tsql2 varchar(500), @tsql3 varchar(1000)
--enclose querystring in doublequotes
set @querystring = '"' + @querystring + '"'
--construct query, pass in querystring
set @TSQL1 = 'SELECT * ' +
'FROM OPENQUERY (FTIndexWeb, ''SELECT path,filename ' +
 'FROM SCOPE('''' "C:\Documents and Settings\user\My Documents\" '''') ' 
set @TSQL2 ='WHERE CONTAINS(contents, ''''' + @querystring + ''''') '')'
-- concat everything
set @tsql3 = @TSQL1 + @TSQL2
--optional
print 'You searched for' + @querystring
-- run query, output row
exec(@TSQL3)
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/19/2004 9:52:06 AM

hihi
(If this comment was disrespectful, please report it.)

 
9/30/2004 7:47:50 PM

I Got Error Message :

Server: Msg 7320, Level 16, State 2, Line 1
Could not execute query against OLE DB provider 'MSIDXS'.
[OLE/DB provider returned message: There is no catalog. ]

What should I do ?

I have :
- Win 2000 Advanced Server + SQL Server 2000 Enterprise Edition.
- Database named : Test
- SQL Server + SQL Server Agent + Indexing Service Already ran on my system
- IS catalog named : web, system ( default catalog ) and mycatalog (c:\inetpub)

(If this comment was disrespectful, please report it.)

 
11/5/2004 10:54:19 AMJaCat

hi, you executed sp_addlinkedserver FTIndexWeb, 'Index Server', 'MSIDXS', 'default'? The 'default' is the catalogname. so execute again with the name of your real catalogs.

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.