Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to change the value of the parameter when call

Author  Topic 

Vaishu
Posting Yak Master

178 Posts

Posted - 2007-09-24 : 17:26:47
Hi
I have below sql procedure
CREATE PROCEDURE  Qty 
@make as nvarchar(32)

AS
select department as category from tblproducts where department = @make
GO


Parameter (@make) will get the value from asp.net page

My Question: Is any possibilities to change the value of parameter when the procedure trigger. Examlpe like below

If @make = 'Sealed Lead Acid' then I need to pass parameter to the database as 'SLA'
elseIf @make = 'Photographic' then 'Multimedia'
elseif @make = 'cctv and accessories' then 'security'

and so on. I only have six categories. Please help

Advance Thanks

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-09-24 : 17:44:45
[code]

select department as category
from tblproducts
where department = (CASE WHEN @make = 'Sealed Lead Acid' THEN 'SLA'
WHEN @make = 'Photographic' then 'Multimedia'
WHEN @make = 'cctv and accessories' then 'security'
END)

[/code]

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-09-25 : 06:56:59
or, you could pass the actual value you need to from the ASP page. Change the VALUE of the dropdown (or radio button or whatever) to what you need, but let the DISPLAY show the other name.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

Vaishu
Posting Yak Master

178 Posts

Posted - 2007-09-25 : 08:59:07
Hi

Thank you very much. It works

quote:
Originally posted by dinakar



select department as category
from tblproducts
where department = (CASE WHEN @make = 'Sealed Lead Acid' THEN 'SLA'
WHEN @make = 'Photographic' then 'Multimedia'
WHEN @make = 'cctv and accessories' then 'security'
END)



Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/

Go to Top of Page
   

- Advertisement -