By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,856 Members | 2,163 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,856 IT Pros & Developers. It's quick & easy.

sql query

P: 11
hi
thanks for your reply i was very helpful for me regarding this i have a problem which is this

i m using this query it works
SELECT AuthorId, UrlUserName, Urlid, UrlAddress, ChooseMedia, Title, Description, ChooseThumbnail, ChooseTopic, Datetime,
(SELECT COUNT(CommentId) AS Expr1
FROM CommentTable
WHERE (CommentUrlid = Submitnewtable.Urlid)) AS cnt, DATEDIFF(second, Datetime, GETDATE()) AS diff
FROM Submitnewtable
WHERE (Title LIKE '%.com%')
BUT I WANT TO USE A TEXTBOX.TEXT OR STRINGVARIABLE IN THE PLACE OF '%.com%' FOR SEACHING purpose
i also used FREETEXT funciton for searching but it not working and give error which is fulltext index.My database table is not fulltext index enabled and i tried to enable fulltext index but i failed please guide me regarding above query


thanks
Nov 10 '09 #1
Share this Question
Share on Google+
2 Replies


nbiswas
100+
P: 149
Hi, coming to ur doubts

Q1) BUT I WANT TO USE A TEXTBOX.TEXT OR STRINGVARIABLE IN THE PLACE OF '%.com%' FOR SEACHING purpose

Ans:

Expand|Select|Wrap|Line Numbers
  1. declare @p varchar(50)
  2. set @p = 'name'
  3. select * from MyTable where attribute like '%' + @p + '%'
will give you the same result as

Expand|Select|Wrap|Line Numbers
  1. select * from MyTable where attribute like '%name%'
You can use this in a stored proc or in inline query.

So your query will be
Expand|Select|Wrap|Line Numbers
  1. WHERE (Title LIKE '%' + @var + '%') where @var will contain '.com'
Q2) My database table is not fulltext index enabled and i tried to enable fulltext index.....

Ans: Look into this

http://www.mssqlcity.com/Articles/Ad...S/SetupFTS.htm

and this

http://www.databasejournal.com/featu...step-Guide.htm

Hope this helps
Nov 11 '09 #2

P: 11
hi
still i have a confusion i m using this query in asp.vb page now i have
Dim strsearch As String
strsearch = txtsearch1.Text
i want to search records form mytable with the value of strsearch
strsearch is input valule for search a record form mytable
please guide me about this

dadsubmit = New SqlDataAdapter("SELECT AuthorId, UrlUserName, Urlid, UrlAddress, ChooseMedia, Title, Description, ChooseThumbnail, ChooseTopic, Datetime, (SELECT COUNT(CommentId) AS Expr1 FROM CommentTable WHERE (CommentUrlid = Submitnewtable.Urlid)) AS cnt,

DATEDIFF(day, Datetime, GETDATE()) AS diff FROM Submitnewtable WHERE title like '%%' &strsearch , consumit)
Nov 11 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.