Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
here is my query

SQL
ALTER PROCEDURE [dbo].[selectDataByDDLValue](@ddlValue varchar(50))
AS
IF @ddlValue = 1
BEGIN
select distinct Fname,Lname from Client_registration_tbl
END
ELSE
BEGIN
  IF @ddlValue = 2
  BEGIN
  select a.Fname,a.Lname, b.Product_name,b.Product_quan,b.Delivery_date  from Client_registration_tbl a , Product_order  b where a.Uname= b.Uname
  END
  ELSE
  BEGIN
  select a.Fname,a.Lname, b.Product_name,b.Product_quan,b.Delivery_date,b.Extend_date  from Client_registration_tbl a , Product_order  b where a.Uname= b.Uname
  END
END




i want to write a column name in place of 1 and 2.....how can i do
Posted
Comments
ssd_coolguy 18-Sep-12 2:50am    
not clear.. can you explain more...
Rashid Choudhary 18-Sep-12 2:52am    
can i write Uname and Delivery_date in place of @ddlValue = 1 and @ddlValue = 2
Kuthuparakkal 18-Sep-12 3:01am    
not clear at all
[no name] 18-Sep-12 3:00am    
Think u are trying to get drop down selected item text and checking in the condition to match... if so, just, do
IF @ddlText = 'ur column name'
THEN doSomething...

1 solution

SQL
ALTER PROCEDURE [dbo].[selectDataByDDLValue](@ddlValue varchar(50))
AS
IF @ddlValue = 'Uname'
BEGIN
select distinct Fname,Lname from Client_registration_tbl
END
ELSE
BEGIN
  IF @ddlValue = 'Delivery_Date'
  BEGIN
  select a.Fname,a.Lname, b.Product_name,b.Product_quan,b.Delivery_date  from Client_registration_tbl a , Product_order  b where a.Uname= b.Uname
  END
  ELSE
  BEGIN
  select a.Fname,a.Lname, b.Product_name,b.Product_quan,b.Delivery_date,b.Extend_date  from Client_registration_tbl a , Product_order  b where a.Uname= b.Uname
  END
END


Happy Coding!
:)
 
Share this answer
 
Comments
Rashid Choudhary 18-Sep-12 3:03am    
thanxxx mam
Aarti Meswania 18-Sep-12 3:09am    
welcome :)
Glad to help you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900