Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

adding a query as parameter using 'contains' logic

 
   Database Forums (Home) -> MSEQ RSS
Next:  Major Search Problem  
Author Message
Texas Tonie

External


Since: Nov 13, 2007
Posts: 1



(Msg. 1) Posted: Tue Nov 13, 2007 12:53 pm
Post subject: adding a query as parameter using 'contains' logic
Archived from groups: microsoft>public>sqlserver>mseq (more info?)

Hello,

Setting parameter ranges for a query is very useful.

How can I specify : begins with ...... and make that a parameter (in this
case first 5 digits of a project name)?

Liek '%[parameter3]%' does not work.

What should it be?

Help much appreciated,

An 'over-his-head' Texas Tonie

 >> Stay informed about: adding a query as parameter using 'contains' logic 
Back to top
Login to vote
Russell Fields

External


Since: Feb 21, 2007
Posts: 457



(Msg. 2) Posted: Wed Nov 14, 2007 2:38 pm
Post subject: Re: adding a query as parameter using 'contains' logic [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Texas Tonie,

If you want a range of values, look at the BETWEEN operator. For character
strings, however, the whole issue of collation and sort order needs to be
considered when defining what is between.

For your example problem, assuming that the 'number' is actually a character
string (not some sort of numeric datatype) and that the number may have
leading spaces, then you could use:

DECLARE @Value = ' 12345'

SELECT @Value WHERE LTRIM(@Value) LIKE '12345%'

FWIW,
RLF

"Texas Tonie" wrote in message

> Hello,
>
> Setting parameter ranges for a query is very useful.
>
> How can I specify : begins with ...... and make that a parameter (in this
> case first 5 digits of a project name)?
>
> Liek '%[parameter3]%' does not work.
>
> What should it be?
>
> Help much appreciated,
>
> An 'over-his-head' Texas Tonie

 >> Stay informed about: adding a query as parameter using 'contains' logic 
Back to top
Login to vote
Hugo Kornelis

External


Since: Jan 31, 2006
Posts: 335



(Msg. 3) Posted: Thu Nov 15, 2007 7:57 pm
Post subject: Re: adding a query as parameter using 'contains' logic [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 13 Nov 2007 12:53:02 -0800, Texas Tonie wrote:

>Hello,
>
>Setting parameter ranges for a query is very useful.
>
>How can I specify : begins with ...... and make that a parameter (in this
>case first 5 digits of a project name)?
>
>Liek '%[parameter3]%' does not work.

Hi Texas Tonie,

Try
LIKE @parameter3 + '%'

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
 >> Stay informed about: adding a query as parameter using 'contains' logic 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Selecting Quarter and Year Parameter - I am working on a report where the end user would like to say giving me data for quarter 1 of 2007,ect. The data in my table has the year and date fields. How do I begin to start this query? I know I can say @Year for the year parameter, but I am no...

Help adding fields to a table - I have a list of values in one field in a table, and I want to modify another table that I have to add a new field for each value in the other field. In case this doesn't make sense, I've posted examples below - Table 1 Field 1 values - Apple, Pear,....

query - Hi, I have some models that have hyhen in between. e.g.1200LD-VCD, abc-1234 May I know how to remove the hyhen. Thank you

query - hi i have some models that end with +SP e.g. 1234+SP, abcd+SP I want to remove only the +SP from these models. May i know how can i do it. Thank you

SQL Query - Hi all, i am not able to make up a query according to my need. can anyone help. Following is my simple query. select udf_name [Severity],st_name [Status], count(2) [count] from bugs, statuses, user_defined_attribute where udf_id =..
   Database Forums (Home) -> MSEQ All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]