473,854 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble using the CONTAINS() function in sql server

I am having trouble using the CONTAINS function in sql
server(enterpri se manager). I am typing the following:

Select *
FROM mytable
WHERE CONTAINS(myfiel d,'mystring')

This returns the error:

Query Designer encountered a MS Design Tools error:
ODBC error:[Microsoft][ODBC SQL Server Driver]'CONTAINS' is not a
recognized
function name.[Microsoft][ODBC SQL Server Driver][SQL
Server]Statement(s) could
not be prepared.

According to the T-SQL reference on msdn this is a supported function?
Am I typing something incorrectly? If this is not supported, is
there an equivalent to this function? In my field I have some comma
delimited values ie 'apple,orange'. So I need to be able to discern
which records contain orange. The LIKE keyword doesn't seem to work
for this scenario. Any help would be greatly appreciated.
Jul 20 '05 #1
3 52209
Works for me. Just add it directly to the SQL statement, unless you're
using an older SQL Server version than 2000?

Another way to do this is to use LIKE, as you mentioned:

select * from mytable where myfield like '%orange%'

HTH,
Dave
"Jason" <jf******@yahoo .com> wrote in message
news:ec******** *************** ***@posting.goo gle.com...
I am having trouble using the CONTAINS function in sql
server(enterpri se manager). I am typing the following:

Select *
FROM mytable
WHERE CONTAINS(myfiel d,'mystring')

This returns the error:

Query Designer encountered a MS Design Tools error:
ODBC error:[Microsoft][ODBC SQL Server Driver]'CONTAINS' is not a
recognized
function name.[Microsoft][ODBC SQL Server Driver][SQL
Server]Statement(s) could
not be prepared.

According to the T-SQL reference on msdn this is a supported function?
Am I typing something incorrectly? If this is not supported, is
there an equivalent to this function? In my field I have some comma
delimited values ie 'apple,orange'. So I need to be able to discern
which records contain orange. The LIKE keyword doesn't seem to work
for this scenario. Any help would be greatly appreciated.

Jul 20 '05 #2
I've never used contains.... Have you tried CharIndex?

Ex:
Select *
FROM tablename
where charindex('stri ngtofind',colum n) > 0

Scott


jf******@yahoo. com (Jason) wrote in message news:<ec******* *************** ****@posting.go ogle.com>...
I am having trouble using the CONTAINS function in sql
server(enterpri se manager). I am typing the following:

Select *
FROM mytable
WHERE CONTAINS(myfiel d,'mystring')

This returns the error:

Query Designer encountered a MS Design Tools error:
ODBC error:[Microsoft][ODBC SQL Server Driver]'CONTAINS' is not a
recognized
function name.[Microsoft][ODBC SQL Server Driver][SQL
Server]Statement(s) could
not be prepared.

According to the T-SQL reference on msdn this is a supported function?
Am I typing something incorrectly? If this is not supported, is
there an equivalent to this function? In my field I have some comma
delimited values ie 'apple,orange'. So I need to be able to discern
which records contain orange. The LIKE keyword doesn't seem to work
for this scenario. Any help would be greatly appreciated.

Jul 20 '05 #3
Great thanks for your help. After posting this question I read on msdn
that some keywords are new for sql server 2000. The "contains" function
is on that list. I tried LIKE "%mystring% " and it works fine!!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2362
by: David C. Holley | last post by:
How would I run a JavaScript function in a *.asp page and then pass the value returned to VBScript for further processing? ***Converting the function to VBScript is *NOT* an option.
2
809
by: serge calderara | last post by:
Dear all, I am populating a treeview control with an XML file. I need to skip duplicate node entry from XML file in treeview if exit For that I ma using the following line of code : If NodeCollection.Contains(node) Then Return True That function always return false.
2
20763
by: sprungli | last post by:
My goal is to select some XPath nodes based on whether their values (text) contain a string passed as argument. To achieve this I use the contains() function of XPath in an XpathExpression. For example, given the following fragment... <code> <Exprs> <Expr>red fox</Expr> <Expr>jump over</Expr>
4
13315
by: BravesCharm | last post by:
I am trying to connect to SQL Server 2005 Express with Visual C# 2005 Express using this code: static void Main(string args) { SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\temp.MDF;User ID=MyUsername;password=MyPass;DATABASE=Test;Integrated Security=False;User Instance=True"); conn.Open();
5
3508
by: tkondal | last post by:
Hi all. I just started looking at Python's ctypes lib and I am having trouble using it for a function. For starters, here's my Python code: from ctypes import*; myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
13
2245
by: arnuld | last post by:
this does not work, i know there is some problem in the "for loop" of "print_arr" function. i am not able to correct the weired results i am getting. i have no compile time error, it is only semantic-bug that is causing the trouble: EXPECTED: january, february, march....december GOT: january, january, january.........january ------------- PROGRAMME -------------- /* Stroustrup, 5.9, exercise 10
0
4478
by: kc7zdm | last post by:
I'm using Oracle intermedia text indices in my database, and the Contains function from a VB.Net program using the system.data.oracleclient provider. When a query includes a number as a search term, it returns zero rows, throws no error when run from the program. The same query run from Toad or SQLPlus properly returns 2 rows as expected. I can't find anything on this in any of the documentation. Has anyone seen this? Any help will be...
0
1827
by: Maxx57 | last post by:
C# VS.Net 1.1 (2003) - trouble with using IE proxy server settings I've got a program that detects if it can connect to a webservice. It sends a System.Net.WebRequest and then checks the information it gets back to findout if it can connect to the service properly. If there is an error it will catch an exception and everything is fine. This used to work wonderfully, until somebody decided they needed to use a proxy server. (rats!) It's...
8
4666
by: SMJT | last post by:
Does anyone know why the string contains function always returns true if the token is an empty string? I expected it to return false. "AnyOldText".Contains("") or "AnyOldText".Contains(String.Empty)
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7083
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5946
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4167
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.