Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fulltext search with MS SQL

Status
Not open for further replies.

pub00515

Programmer
Aug 31, 2006
2
DE
Hello,

I am trying to implement a fulltext search on a MS SQL database. While I can query each table independently for a specific word, I didn't find a method to query the entire collection of tables for my search key. Is there a way to do this (using the fulltext catalog for example)?

Thanks!

Mark
 
You would need to use CONTAINSTABLE and INNER JOIN the CONTAINSTABLE statements together.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Hi Denny,

thanks for your answer! I'm pretty new to this so I don't really see the solution yet.

My problem is that I don't know the names of my tables (nor the ID's) and I don't know how many tables there are (could be 2, could be 100). I just want to perform a query where I can find out in which tables I can find the word "test" for example. At this point I don't care in which column the data is or how many columns are indexed. Is this possible?

Thanks again,

Mark
 
you should try doing all dinamicly. it`s hard , but when you do that, many of your problems will be solved.
 
Using dynamic SQL can be very complex, and it requires opening up the security on the objects quite a bit.

If you work in a shop where the security is locked down dynamic SQL may not be an option.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Hello, what is the diffrence between a CONTAINSTABLE and CONTAINS? Just curious, I am new to using fulltext catalogs.

Babloome
 
With CONTAINS you have to tell SQL which column to look at. CONTAINS table looks at all the columns in the table.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
With CONTAINS you have to tell SQL which column to look at. CONTAINSTABLE looks at all the columns in the table.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
So which is faster?
Code:
contains(*,'"vb" and ".net"')

containsTable('"vb" and ".net"')

If it matters i am using sql 2005

Thanks for all your help.

Babloome

 
They should be the same as they are doing the same thing. Check the execution plan to be sure.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top