TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mahesh Babu
NA
118
32.3k
how to use the if-else condition in storedprocedure
Aug 24 2018 1:07 AM
My Requirement is:
I need to check
1.if Empid is Null or not?
If it is Null I need to display the message
2, if Empid exist or not in the table
if Empid exists I need to display the record
3. If FinancialYear is is Null or not?
4. if financial year exist or not in the table
5. Based on the Empid I need to get the FinancialYear
6.After getting the financial year If the financial year is existed or not in the table
Below u can find the code
pLease help me this
ALTER PROCEDURE [dbo].[SPBudget]
@empID varchar(50),
@financialYear varchar(50),
@cost varchar(50)
AS
BEGIN
Declare @records varchar(max)
Declare @Financial varchar(max)
Declare @Cost varchar(max)
IF ISNULL(@empId,0)!=0
BEGIN
if(select Count([Num]) from [Employee] where [Num]=@empId)<=0
set @records='empid doesnot exist'
select @records as [EmpID]
END
IF ISNULL(@financialYear,0)!=0
BEGIN
if(select Count( [FinancialYear]) from [Expense] where [FinancialYear]=@financialYear)<=0
set @Financial='Year doesnot exist'
select @Financial as [FinancialYear]
END
IF(@cost!=0)
BEGIN
if(select Count( [Cost]) from [Employee] where [Cost]=(select [Cost] from [Employee] where [Num]=@empId))<=0
if(@cost=@empId)
begin
select * from [Employee]
END
Else
begin
set @Cost ='cost doesnot exist'
end
END
END
Reply
Answers (
3
)
about entity framework auto-generated model class object
System.Web.MVC version 4.0.20710 taking more time to execute