Showing posts with label test1. Show all posts
Showing posts with label test1. Show all posts

Monday, March 12, 2012

How to dynamic specify the colums in Full-Text Search?

My problem is simple: i want to dynamic specified the columns in the ContainsTable, this is possible? Please see the example.


Declare @.Test1 int
Declare @.Test2 int
Declare @.Query varchar(50)
Declare @.Temp varcahr(50)

--Test
Set @.Test1=1
Set @.Test1=0
Set @.Query='something'

--Add the column to put in containstable
IF (@.Test1=1)
Begin
Set @.Temp='ID'
End

IF (@.Test2=1)
Begin
Set @.Temp= @.Temp + ',Name'
End

SELECT *
FROM
<table>
INNER JOIN
CONTAINSTABLE (<table>,@.Temp, @.Query) AS KEY_TBL
ON <table>.ID = KEY_TBL.[KEY]

ThanksOnly in Sql Server 2005 (Yukon) that is possible... :/