We help IT Professionals succeed at work.

tricky stored procedure

Wigging
Wigging asked
on
399 Views
Last Modified: 2012-06-27
lets say that i have 2 parameters that come from  my website
@model
@max_price

based on the results of these parameters and want my SP to get results  from
 select model, max_price
from table
where model=@model     and max_price=@price

the only tricky part is that  the column model  has the  data in comma separated so we might have to do a split.
LT40 Manual,LT40 Hydraulic


Comment
Watch Question

CERTIFIED EXPERT
Awarded 2008
Awarded 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
can u help me biuld it?
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
read the article first.  If you have questions after that I can help.
select model, max_price
from table
where CharIndex(@model, mode) > 0      and max_price=@price
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Oops. It's AngelIII not 2 lol :)
And the correct syntax is
select model, max_price
from table
where max_price=@price and model in (select * from dbo.ParmsToList(@model, ','))  
J K

Commented:
CREATE PROCEDURE SP_MODEL
@model varchar
@max_price float
AS
BEGIN

select * from TABLE_NAME where model like @model+',%' or model like '%,'+@model or model like '%,'+@model+',%' and max_pice=@max_price

END
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
Its the same answer as what I originally posted....

Author

Commented:
ohh i am sorry.   how can i revert this?
CERTIFIED EXPERT
Awarded 2008
Awarded 2008

Commented:
Ive posted a request for attention....EE will get to it.

Commented:
Well, I wouldn't say is the same answer. The reason I've posted, is because the asker wanted some help in customizing it to his needs. :) Having said that, I would suggest a split.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.