Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
This Query is Work : use for insert
SQL
INSERT INTO Employee VALUES(@EmployeeID,@EmployeeName,@Emp_Title,@Address_1, @Address_2,@Area, case when @City<=0 then null else @City end,
        @Postcode,@JoiningDate,@BirthDate,@LeavingDate,case when @DepartmentID <=0 then null else @DepartmentID end, case when @DesignationID<=0 then null else @DesignationID end, @MobileNo,@Office_PhoneNo,@Residence_PhoneNo,@Email_ID,@Active);


i also want to use case here but not Works
SQL
Update Employee Set EmployeeName=@EmployeeName,Emp_Title=@Emp_Title,Address_1=@Address_1,Address_2=@Address_2,Area=@Area,City=@City,Postcode=@Postcode,JoiningDate=@JoiningDate,BirthDate=@BirthDate,LeavingDate=@LeavingDate,DepartmentID=@DepartmentID,DesignationID=@DesignationID,MobileNo=@MobileNo,Office_PhoneNo=@Office_PhoneNo,Residence_PhoneNo=@Residence_PhoneNo,Email_ID=@Email_ID,Active=@Active WHERE EmployeeID =  @EmployeeID



any one help me to out This...!!
Posted
Updated 15-Sep-12 1:28am
v2
Comments
[no name] 15-Sep-12 7:06am    
both are same query but only change is Case condition
Ganesh Nikam 15-Sep-12 7:28am    
can you specify what is error
__TR__ 15-Sep-12 7:30am    
What's the error message you got ?
[no name] 19-Sep-12 8:09am    
i Solved Problem Thx....
Pete O'Hanlon 19-Sep-12 10:14am    
I have removed your abusive comments below. They are not acceptable on a site like Code Project. In future, please try not to be abusive.

Hi,

Check http://www.bennadel.com/blog/933-Using-CASE-Statements-In-A-SQL-UPDATE-Query.htm[^] very simple but it will explain Case in Update query.

Hope you got the answer from this link,
 
Share this answer
 
Comments
[no name] 15-Sep-12 7:43am    
Perfect Ans.

Thx a lot....:)
AmitGajjar 15-Sep-12 7:43am    
Your welcome dear.
Finally. i got solution for this Problem.
problem is circular execute SP.
 
Share this answer
 

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