473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

substring matching

hi all
I want to write a sotred procedure which has a parameter,called
@name.The SQL statement must return all rows where this parameter is a
subatring of a special column called FirstName.This procdeure do the
same ,but return all rows where @name is the exact matching.what
should I do?
/*
This procedure return the exact matching
*/
CREATE PROCEDURE substring
@name varchar(50)
AS
SELECT *
FROM table1
WHERE (table1.firstName LIKE @name);

Jul 19 '07 #1
2 3488
anoosh (pa****@gmail.com) writes:
I want to write a sotred procedure which has a parameter,called
@name.The SQL statement must return all rows where this parameter is a
subatring of a special column called FirstName.This procdeure do the
same ,but return all rows where @name is the exact matching.what
should I do?
/*
This procedure return the exact matching
*/
CREATE PROCEDURE substring
@name varchar(50)
AS
SELECT *
FROM table1
WHERE (table1.firstName LIKE @name);
LIKE '%' + @name + '%'
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jul 19 '07 #2
Based on you narrative, the query you need is:

SELECT *
FROM table1
WHERE @name LIKE '%'+table1.firstName+'%'

HTH,
Gert-Jan
anoosh wrote:
>
hi all
I want to write a sotred procedure which has a parameter,called
@name.The SQL statement must return all rows where this parameter is a
subatring of a special column called FirstName.This procdeure do the
same ,but return all rows where @name is the exact matching.what
should I do?

/*
This procedure return the exact matching
*/
CREATE PROCEDURE substring
@name varchar(50)
AS
SELECT *
FROM table1
WHERE (table1.firstName LIKE @name);
Jul 19 '07 #3

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

Similar topics

6
by: Tarun | last post by:
Hi All, I need to find a particular substring in a binary string(some text appended & prepended to binary data). I cant use strstr since it terminates on receiving '\0'which can be there in...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
3
by: colinhumber | last post by:
How can I use regular expressions to search for a substring within another substring? For example, if I have the string: "This is * some text <button id="123">Some * text</button>" and I only...
6
by: joseph speigle | last post by:
hi, Does anybody know offhand what is the correct way to use substr to extract the domain name from a client_referer column as logged by mod_pgsqllog (httpd module), by correcting the following: ...
6
by: likong | last post by:
Hi, Any idea about how to write a regular expression that matches a substring xxx as long as the string does NOT contain substring yyy? Thanks. Kong
7
by: Kevin CH | last post by:
Hi, I'm currently running into a confusion on regex and hopefully you guys can clear it up for me. Suppose I have a regular expression (0|(1(01*0)*1))* and two test strings: 110_1011101_ and...
2
by: Rob | last post by:
I've just about beat my brains all the way out on this one. Is anyone up to the amazingly ridiculous challenge of figuring this one out? Here's the code, followed by my question: <script...
2
by: Moham12345 | last post by:
Hi, Im struggling here ... is it possible to check for a string pattern like a valid url in a bigger string. And then return the matching pattern string? so if i had a string like : "This...
5
by: Kris Kennaway | last post by:
I am trying to parse a bit-stream file format (bzip2) that does not have byte-aligned record boundaries, so I need to do efficient matching of bit substrings at arbitrary bit offsets. Is there a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.