| View previous topic :: View next topic |
| Author |
Message |
Marx
Joined: 02 Nov 2007 Posts: 9
|
Posted: Wed May 21, 2008 6:42 am Post subject: how to write if statement in sql server stored procedure. |
|
|
hi experts,
i have developed a web application using asp.net. in this my application is interacting with sql server database. for this i have to use stored procedures concept instead of dynamic queries for the sake of site performance. can any any one suggest me how to write a stored procedure with conditional statement to get data from my table.
thanking you in advance,
regards,
max |
|
| Back to top |
|
 |
deepak patel
Joined: 27 Aug 2007 Posts: 14
|
Posted: Wed May 21, 2008 7:04 am Post subject: |
|
|
hi max,
developing a web application with the help of stored procedure instead of dynamic stored procedure improved site performance. here is the sample stored procedure for selecting data from employees table by employeesId and getting all employees information with only one single stored procedure with the help of conditional statements.
Create PROCEDURE [dbo].sp_Select_Employees
@EmployeeId int,
@Option varchar(15)
as
begin
if(@Option ='All')
select * from employees
else
select * from employees where employeeId=@EmployeeId
end
here @Option is a variable which stores search information.
try this procedure...and enjoy the codding...keep doing postings... |
|
| Back to top |
|
 |
|