Showing posts with label word. Show all posts
Showing posts with label word. Show all posts

Monday, March 26, 2012

finding a word, submitting part of it

Dear All

Does anyone know any syntax that will allow me to find entries in a atable when only part of a word is entered. I have a table that has been full txt indexed at the moment I am using the CONTAINS keyword to search fields. This works fine 'select * from tblX where contains(colX, 'gill')', gives me back what i want, but what if i type this 'select * from tblX where contains(colX, 'ill')' it doesn't find anything. What i want is a command that will search all the words in a table column. Does anyone know of a command that will do this?

ThanksI got into the CONTAINS (T-SQL) syntax, and I found only prefix_terms like 'ill*', but I didn't found a solution for a '*ill' condition. Using the LIKE operator isn't an option either. I hope that other guys can help you. :(|||Well, LIKE is an option, just not a very efficient one. But, it's there for just this type of search.

SELECT * FROM tblX WHERE colX LIKE '%ill'

You can also replace the wildcard % with:

_ looks for any single char

[] looks for any chars or range of chars you specify ([a-q], [abcd], [1-9], etc)

[^] same as above, but exclusion chars ([^a-f] means anything but a through f)|||Another option is to use CHARINDEX:

where charindex('ill', colx) > 0

I don't know how this compares to LIKE for speed, but I suspect it would be faster because it has less functionality (no wildcards) and thus may have less processing overhead.

blindman|||I think you are right. Though, any time you ask SQL to do string processing, you are going to take a hit. They seem to have build in several levels of functionality here, getting progressively deeper as you need them. Can't think of why they would do that vs a sigle flexible function, unless the performance would dive.

Wednesday, March 7, 2012

Find Exact word in Full-Text Search

Hi,

I have the fields like this.

Session1 Session2 Session3 Session4
---------------------------
SQL Server-Part1 SQL Server-Part2 ASP.Net CSS

C# SQL Server-Part3 ASP.Net Javascript

I have set the Full-Text to all the columns. For searching i wrote the below query

SELECT * FROM <TABLE NAME> WHERE CONTAINS(*,'"SQL Server-Part1"')

My Result expectation is: The First Record should come. But the result of the query bring the two records. It see the "SQL Server" string also. I need to find the exact word. How to do it?

Please answer me as soon as possible.


Ganesh.

Hi there,

Why don't you try this:

SELECT TOP 1 * FROM <TABLE NAME> WHERE CONTAINS(*,'"SQL Server-Part1"')

Hope this helps,

thanks,

Murthy here

|||

Murthy Puvvada:

Hi there,

Why don't you try this:

SELECT TOP 1 * FROM <TABLE NAME> WHERE CONTAINS(*,'"SQL Server-Part1"')

Hope this helps,

thanks,

Murthy here

Sorry, but I think that is bad sql advice!

There is no guarantee that the correct record will be returned first in the query. Next time, it could be the second record returned.

In fact, if there is no order by clause, the sql standard maintains that the order of records returned in indeterminate, meaning officially unpredictable. Any sub-sub-release of sql server (or any other sql database) is free to make internal performance enhancements that could result in the records being returned in a different order.


|||

On another note, I haven't used Full Text indexing yet. Sorry, I can'tgive definitive advice there. But I'm guessing, from the sample datathat you showed, that maybe some of the characters you typed are wildcards of some sort within the context of the Contains function. Beingignorant on Full Indexing, I would read up on the specifications forthe Contains function more carefully.

And why do you have both single and double quotes around the search string? It sure looks weird!

|||

Oh! No. I can not use SELECT TOP 1 . Because the table may have duplicate of the string in more than a time.

So, please give me the exact answer.

Thanks

|||

Again, you need to research the Contains function and what it does. It clearly brings back data that you do not expect it to.

Have you researched that function yet?

|||

I glanced at the online documentation for the contains function and the mdx language for the search parameter.

It looks like it treats a - character as an Except command in some circumstances. I noticed that you had a - in the text you were searching for.

Might want to do an experiment and see if that's the problem.

Sunday, February 26, 2012

find and replace

how do i write a query that will go through all the rows of a text field and
replace the search word with a new word.
like the find and replace feature in MS Access
REPLACE "ABC" WITH "CBS" IN DBTABLE.DBTEXT
Thanks,
AaronHi,
Use Update statement with Replace function in SET clause. This will work out
if ur data type is
Varchar/Char/Nchar,Nvarchar.
Thanks
Hari
SQL Server MVP
"Aaron" <kuya789@.yahoo.com> wrote in message
news:uvdHyxNOFHA.3396@.TK2MSFTNGP10.phx.gbl...
> how do i write a query that will go through all the rows of a text field
> and replace the search word with a new word.
> like the find and replace feature in MS Access
> REPLACE "ABC" WITH "CBS" IN DBTABLE.DBTEXT
> Thanks,
> Aaron
>|||Could you give me an example?
"Hari Pra" <hari_pra_k@.hotmail.com> wrote in message
news:Oormu$NOFHA.904@.tk2msftngp13.phx.gbl...
> Hi,
> Use Update statement with Replace function in SET clause. This will work
> out if ur data type is
> Varchar/Char/Nchar,Nvarchar.
> Thanks
> Hari
> SQL Server MVP
> "Aaron" <kuya789@.yahoo.com> wrote in message
> news:uvdHyxNOFHA.3396@.TK2MSFTNGP10.phx.gbl...
>|||Aaron
CREATE TABLE #Test
(
col VARCHAR(10)
)
INSERT INTO #Test VALUES ('FDABC')
UPDATE #Test SET col=REPLACE(col,'ABC','CBS')
--or if you know the start point and length of the string
UPDATE #Test SET col=STUFF(col,3,3,'CBS')
SELECT * FROM #Test
"Aaron" <kuya789@.yahoo.com> wrote in message
news:eSVOunOOFHA.2520@.tk2msftngp13.phx.gbl...
> Could you give me an example?
>
> "Hari Pra" <hari_pra_k@.hotmail.com> wrote in message
> news:Oormu$NOFHA.904@.tk2msftngp13.phx.gbl...
field
>

Friday, February 24, 2012

Find a word in entire database

SQL server 2000
Hi
I want to search a field value in entire database.
Example: Search for word "Ontario" in all rows of all tables in the
database. I do not want to search column_names but basically all rows in all
columns of the database for a particular word.
Thanks
ontario, canada
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
Kevin3NF
SQL Server dude
You want fries with that?
http://kevin3nf.blogspot.com/
I only check the newsgroups during work hours, M-F.
Hit my blog and the contact links if necessary...I may be available.
"db" <db@.discussions.microsoft.com> wrote in message
news:5B906D6F-9018-41C2-BB73-22A4AACDF41F@.microsoft.com...
> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in
> all
> columns of the database for a particular word.
> Thanks
> ontario, canada
|||If you need to do rather convoluted search (e.g. with regular expressions),
you could also consider dump everything out to files and search files for
your string. Probably more troublesome than it's worth, but could be useful
for certain scenarios.
Linchi
"db" wrote:

> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in all
> columns of the database for a particular word.
> Thanks
> ontario, canada
|||IIRC ApexSQL Edit has this functionality built in. Pretty slick.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"db" <db@.discussions.microsoft.com> wrote in message
news:5B906D6F-9018-41C2-BB73-22A4AACDF41F@.microsoft.com...
> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in
> all
> columns of the database for a particular word.
> Thanks
> ontario, canada

Find a word in entire database

SQL server 2000
Hi
I want to search a field value in entire database.
Example: Search for word "Ontario" in all rows of all tables in the
database. I do not want to search column_names but basically all rows in all
columns of the database for a particular word.
Thanks
ontario, canadahttp://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
--
Kevin3NF
SQL Server dude
You want fries with that?
http://kevin3nf.blogspot.com/
I only check the newsgroups during work hours, M-F.
Hit my blog and the contact links if necessary...I may be available.
"db" <db@.discussions.microsoft.com> wrote in message
news:5B906D6F-9018-41C2-BB73-22A4AACDF41F@.microsoft.com...
> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in
> all
> columns of the database for a particular word.
> Thanks
> ontario, canada|||If you need to do rather convoluted search (e.g. with regular expressions),
you could also consider dump everything out to files and search files for
your string. Probably more troublesome than it's worth, but could be useful
for certain scenarios.
Linchi
"db" wrote:
> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in all
> columns of the database for a particular word.
> Thanks
> ontario, canada|||IIRC ApexSQL Edit has this functionality built in. Pretty slick.
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"db" <db@.discussions.microsoft.com> wrote in message
news:5B906D6F-9018-41C2-BB73-22A4AACDF41F@.microsoft.com...
> SQL server 2000
> Hi
> I want to search a field value in entire database.
> Example: Search for word "Ontario" in all rows of all tables in the
> database. I do not want to search column_names but basically all rows in
> all
> columns of the database for a particular word.
> Thanks
> ontario, canada

Find / Search for a string in stored procedure?

Hi, I would like to find all the cases within all the stored procedures in a
database where a particular word exists.
Any suggestions? Thanks in advance.
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%YourWord%'
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
|||Try,
use northwind
go
declare @.s varchar(25)
set @.s = 'orders'
select distinct
object_name([id])
from
syscomments
where
objectproperty([id], 'IsProcedure') = 1
and patindex('%' + @.s + '%', [text]) > 0
go
AMB
"rh" wrote:

> Hi, I would like to find all the cases within all the stored procedures in a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
>
|||http://www.aspfaq.com/2037
http://www.aspfaq.com/
(Reverse address to reply.)
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
|||I discussed this at:
http://vyaskn.tripod.com/sql_server_...edure_code.htm
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>

Find / Search for a string in stored procedure?

Hi, I would like to find all the cases within all the stored procedures in a
database where a particular word exists.
Any suggestions? Thanks in advance.SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%YourWord%'
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||Try,
use northwind
go
declare @.s varchar(25)
set @.s = 'orders'
select distinct
object_name([id])
from
syscomments
where
objectproperty([id], 'IsProcedure') = 1
and patindex('%' + @.s + '%', [text]) > 0
go
AMB
"rh" wrote:

> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
>|||http://www.aspfaq.com/2037
http://www.aspfaq.com/
(Reverse address to reply.)
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||I discussed this at:
http://vyaskn.tripod.com/sql_server...cedure_code.htm
--
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>

Find / Search for a string in stored procedure?

Hi, I would like to find all the cases within all the stored procedures in a
database where a particular word exists.
Any suggestions? Thanks in advance.SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%YourWord%'
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||Try,
use northwind
go
declare @.s varchar(25)
set @.s = 'orders'
select distinct
object_name([id])
from
syscomments
where
objectproperty([id], 'IsProcedure') = 1
and patindex('%' + @.s + '%', [text]) > 0
go
AMB
"rh" wrote:

> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
>|||http://www.aspfaq.com/2037
http://www.aspfaq.com/
(Reverse address to reply.)
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||I discussed this at:
http://vyaskn.tripod.com/sql_server...cedure_code.htm
--
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>

Find / Search for a string in stored procedure?

Hi, I would like to find all the cases within all the stored procedures in a
database where a particular word exists.
Any suggestions? Thanks in advance.
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%YourWord%'
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
|||Try,
use northwind
go
declare @.s varchar(25)
set @.s = 'orders'
select distinct
object_name([id])
from
syscomments
where
objectproperty([id], 'IsProcedure') = 1
and patindex('%' + @.s + '%', [text]) > 0
go
AMB
"rh" wrote:

> Hi, I would like to find all the cases within all the stored procedures in a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
>
|||http://www.aspfaq.com/2037
http://www.aspfaq.com/
(Reverse address to reply.)
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
|||I discussed this at:
http://vyaskn.tripod.com/sql_server_...edure_code.htm
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>

Find / Search for a string in stored procedure?

Hi, I would like to find all the cases within all the stored procedures in a
database where a particular word exists.
Any suggestions? Thanks in advance.SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%YourWord%'
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||Try,
use northwind
go
declare @.s varchar(25)
set @.s = 'orders'
select distinct
object_name([id])
from
syscomments
where
objectproperty([id], 'IsProcedure') = 1
and patindex('%' + @.s + '%', [text]) > 0
go
AMB
"rh" wrote:
> Hi, I would like to find all the cases within all the stored procedures in a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>
>|||http://www.aspfaq.com/2037
--
http://www.aspfaq.com/
(Reverse address to reply.)
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>|||I discussed this at:
http://vyaskn.tripod.com/sql_server_search_stored_procedure_code.htm
--
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"rh" <rherrera@.smci.com> wrote in message
news:OCKPvd1HFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi, I would like to find all the cases within all the stored procedures in
a
> database where a particular word exists.
> Any suggestions? Thanks in advance.
>