Hello,
I want to use CONTAINS to search for charater patterns instead of using LIKE
. Here is an example:
Instead of,
Select *
from Northwind.dbo.Categories
Where Description LIKE '%ee%'
I want to use something like,
Select *
from Northwind.dbo.Categories
Where CONTAINS(Description, ' "*ee*" ')
But this doesn't seem to work. I know that the same syntax without the first
'*' works equivalent to LIKE 'ee%'.
Any suggestions?
FarhanContains is used for Full Text Search. Do you have a full text index on
that table?
David Gugick
Imceda Software
www.imceda.com|||Hi,
Thanks for your reply. Every thing is set up correctly, its just that I cant
get CONTAINS to behave as LIKE '%abc%' sort of syntax.
Farhan
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:%23D23q$YKFHA.2800@.TK2MSFTNGP10.phx.gbl...
> Contains is used for Full Text Search. Do you have a full text index on
> that table?
> --
> David Gugick
> Imceda Software
> www.imceda.com
>|||Farhan Noor Qureshi wrote:
> Hi,
> Thanks for your reply. Every thing is set up correctly, its just that
> I cant get CONTAINS to behave as LIKE '%abc%' sort of syntax.
> Farhan
>
I think without the first "*" is what you want.
David Gugick
Imceda Software
www.imceda.com|||If I remove the first *, it behaves as LIKE 'abc%' which is a good feature.
But I need to run an equivalent of LIKE '%abc%'.
Farhan
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OZv5jKbKFHA.3340@.TK2MSFTNGP14.phx.gbl...
> Farhan Noor Qureshi wrote:
>
> I think without the first "*" is what you want.
> --
> David Gugick
> Imceda Software
> www.imceda.com|||Farhan & Dave,
Farhan, the leading "*" (asterisk) wildcard in the search condition is
ignored and this is by design for SQL Server 7.0, 2000 and 2005.
SQL FTS only supports a trailing "*" (asterisk) wildcard, i.e.. a wildcard
word-based suffix search, for example, a search for "book*" will find book,
books, booking & booked. A leading "*" (asterisk) wildcard is not supported
because unlike T-SQL LIKE, SQL FTS is a language-specific linguistic search
method, while LIKE is a grep or pattern search method. Would you want to
search on "*og" and find God and Log in the same results?
Regards,
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Farhan Noor Qureshi" <fqureshi@.N-O-S-P-A-MAiroom.com> wrote in message
news:ep1QTbcKFHA.3640@.TK2MSFTNGP12.phx.gbl...
> If I remove the first *, it behaves as LIKE 'abc%' which is a good
feature.
> But I need to run an equivalent of LIKE '%abc%'.
> Farhan
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:OZv5jKbKFHA.3340@.TK2MSFTNGP14.phx.gbl...
>
Showing posts with label abc. Show all posts
Showing posts with label abc. Show all posts
Saturday, February 25, 2012
Friday, February 10, 2012
Consolidating Like Items and Summing Totals
I need to know if there is an easy way to consolidate lines of the same item but differing quantities.
For example:
ITEM QTY
-- --
ABC 1
ABC 3
ABC 6
ABD 2
ABD 1
ABE 1
I would like to display this information as:
ITEM QTY
-- --
ABC 10
ABD 3
ABE 1
Summary: I want to consolidate those items which appear in the table more than once by combining their quantities and leaving one row that has the sum of all.
Your help is greatly appreciated.
TechRickselecting the totals is easy, right?
select ITEM, SUM(QTY)
from yourtable
group by ITEM
however, consolidating them and "leaving one row" is tricky
i suggest writing the total rows to a temporary table, deleting all rows from the original, then inserting the total rows back
create table temptable
( ITEM char(3)
, QTY integer )
insert into temptable
select ITEM, SUM(QTY)
from yourtable
group by ITEM
delete from your table
insert into yourtable
select * from temptable
drop temptable
rudy
http://rudy.ca/|||Thanks for the help. I was able to get it worked out with your suggestions.
Best Regards,
TechRick
For example:
ITEM QTY
-- --
ABC 1
ABC 3
ABC 6
ABD 2
ABD 1
ABE 1
I would like to display this information as:
ITEM QTY
-- --
ABC 10
ABD 3
ABE 1
Summary: I want to consolidate those items which appear in the table more than once by combining their quantities and leaving one row that has the sum of all.
Your help is greatly appreciated.
TechRickselecting the totals is easy, right?
select ITEM, SUM(QTY)
from yourtable
group by ITEM
however, consolidating them and "leaving one row" is tricky
i suggest writing the total rows to a temporary table, deleting all rows from the original, then inserting the total rows back
create table temptable
( ITEM char(3)
, QTY integer )
insert into temptable
select ITEM, SUM(QTY)
from yourtable
group by ITEM
delete from your table
insert into yourtable
select * from temptable
drop temptable
rudy
http://rudy.ca/|||Thanks for the help. I was able to get it worked out with your suggestions.
Best Regards,
TechRick
Labels:
abc,
consolidate,
consolidating,
database,
differing,
exampleitem,
item,
items,
lines,
microsoft,
mysql,
oracle,
qty-,
quantities,
server,
sql,
summing,
totals
Subscribe to:
Posts (Atom)