Click here to Skip to main content
15,077,377 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have 3 tables in my database and i have a column news varchar(max) in all 3 tables and i want to search a given text in all the tables and want to know in which table that text is present.what will be the query?
Updated 27-Oct-13 20:48pm
TrushnaK 28-Oct-13 2:56am
what you have tried so far....
post you tried query and table stucture.

You can use full text search for each table:
SELECT id,news FROM products WHERE CONTAINS(news, "words to search here")

Please refer the link : SQL Full Text Search Programming[^]
lets say there are 3 tables employee,student,employer and all three has a Address column
use this query to see in which table the text is available.

SELECT		a.Address as employeeAddress,
			b.Address as studentaddress,
			c.Address as employeraddress
FROM		employee	a left outer join
			student		b
			on a.empcode = b.stid
			left outer join
			employer	c
			on b.stid = c.EmployerCode			
where		(
			a.Address	like '%texttobesearched%'
			b.Address	like '%texttobesearched%'
			c.Address	LIKE '%texttobesearched%'

Hope this helps!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900