Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 15th, 2008, 01:14 AM
Registered User
 
Join Date: Mar 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ilayaraja
Default Tag Search and Tag Cloud Search

i'm having the following values in my table

books catalog, education, best books
Birthday, Party Gopi
Session study, usercontrol
Session, study
Holiday
Technical Session, Asp.net
Patterns, session, asp.net
day, party
events for Lords, daily thing
events manager
events things
meeting, administrator
marriage
project ,event, demo
madurai ,event
demo, event calendar
rangoli, event
Demo Project
event project

i want to find an value which is separator by "," or an single word..
for example if my search string "Session" it should return only two result...
but it is returning 4 results.. i need an exact match of my keyword..
in my follwing values all are tags.. my tags may me "technical session" "Session" "Session" "Session Study" but i need an exact match should return only wat im searching ..

 
Old April 15th, 2008, 05:11 AM
Registered User
 
Join Date: Mar 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ilayaraja
Default

FRIENDS I HAVE FOUND THE RESULT FOR TAG SEARCH WITHIN A COLUMN IF ANYONE FIND EFFECTIVE WAY TO FIND THE RESULT PLEASE MAIL ME...

ALTER PROC [dbo].[spEventTagCloudSearch]
@MYSEARCH VARCHAR(2000)
as
BEGIN
DECLARE @RECORDCOUNT INT;
DECLARE @SearchString varchar(2000);
DECLARE @QRY VARCHAR(2000);
DECLARE @SE VARCHAR(2000);
SELECT @RECORDCOUNT=COUNT(*) FROM TBEVENTS
DECLARE @ST INT;
DECLARE @TEMPEVENTID INT;
SET @ST=1;
CREATE TABLE #TEMP2
(
MYTAGS VARCHAR(2000),
EVENTID INT
)
CREATE TABLE #TEMP3
(
EVENTID INT
)
CREATE TABLE #TEMP1
(
STR1 VARCHAR(2000)
)
WHILE @ST<=@RECORDCOUNT
BEGIN
SET @QRY='SELECT TOP ' +CONVERT(VARCHAR,@ST)+' EVENTTAG FROM TBEVENTS'
INSERT INTO #TEMP1 EXEC (@QRY)
SELECT @SEARCHSTRING=STR1 FROM #TEMP1
SELECT @TEMPEVENTID =EVENTID FROM TBEVENTS WHERE EVENTTAG=@SEARCHSTRING
SET @ST=@ST+1
declare @i1 int;
declare @i2 int;
declare @MatchType int ;
set @MatchType=0;
declare @Word varchar(100);
declare @Words table (Word varchar(100) not null);
declare @WordCount as integer;
DECLARE @TEMPWORD VARCHAR(2000);
begin
set nocount on
if (@MatchType != 2)
begin
set @SearchString = ' ' + @SearchString + ',';
set @i1 = 1;
while (@i1 != 0)
begin
set @i2=charindex(',', @SearchString, @i1+1)
if (@i2 != 0)
begin
set @Word = rtrim(ltrim(substring(@SearchString, @i1+1, @i2-@i1)))
SET @TEMPWORD=@WORD;
SET @TEMPWORD=REPLACE(@TEMPWORD,',','')
INSERT INTO #TEMP2 SELECT @TEMPWORD,@TEMPEVENTID
if @Word != '' insert into @Words select replace(@Word,',','')
end
set @i1 = @i2
end
end
else
insert into @Words select ltrim(rtrim(@SearchString))
set @WordCount = (select count(*) from @Words)
END
END
SET @QRY= 'SELECT EVENTID FROM #TEMP2 WHERE MYTAGS='''+CONVERT(VARCHAR,@MYSEARCH)+''''
INSERT INTO #TEMP3 EXEC (@QRY)
SELECT @RECORDCOUNT=COUNT(*) FROM #TEMP3
SELECT * FROM TBEVENTS A INNER JOIN #TEMP3 B ON A.EVENTID=B.EVENTID
DROP TABLE #TEMP1
DROP TABLE #TEMP2
DROP TABLE #TEMP3
END






Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button doesn't search Access DB cbones Visual Studio 2008 1 October 27th, 2008 07:36 PM
File Search / Indexing Search with .net 2.0 maulik77 ASP.NET 1.0 and 1.1 Basics 2 March 15th, 2007 12:45 AM
HTML tag from C# or ASP.NET tag from javascript angshujit ASP.NET 2.0 Basics 3 February 16th, 2007 10:07 AM
HTML tag vs Body Tag CFGerry BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 October 7th, 2005 07:13 AM
Trying to output a tag within a tag jaucourt XSLT 3 January 12th, 2005 11:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.