I have declared two parameters in Stored Procedures.
I want to write 2 sections.
One section has only one parameter. So I used that parameter only. If I didnt mentions the 2nd parameter in coding means It shows an error.
For Ex.
Fname varchar(50),
DOB Date,
flag varchar(50)
===============
if flag='NameWise' then
select * from tbl_sample where FirstName=Fname;
elseif flag='DateWise' then
select * from tbl_sample where DateofBirth=DOB;
end if;
====================
?????
From the Above when If use 'Name Wise' means I will pass only the 'name'. So It shows 'DOB' error which has not declared.
Reply me soon. Please
JesupriyanPosted Feb 16, 2010, 4:43 AM
Amit ChoudharyPosted Feb 15, 2010, 5:21 AM
well if you want some thing like parameter array then you can go to the following article will tell you how to pass any no. of parameters:
http://weblogs.asp.net/dwahlin/archive/2007/02/16/passing-an-array-of-values-to-a-stored-procedure-in-sql-server-2005.aspx
Don't forget to mark the answer if it helps.
JesupriyanPosted Feb 15, 2010, 4:45 AM
Amit ChoudharyPosted Feb 15, 2010, 4:23 AM
As i understood with your problem specified
I suggest you to create a stored procedure that takes 3 arguments, first is your flag and according to flag you can pass the value of DOB or fname.
if you call SP with flag value 'NameWise' then send the fname and pass DOB as Empty string.
or if you call SP with flag value 'DateWise' then send the DOB and pass fname as Empty string.
Please mark the answer if it helps you.