Click here to Skip to main content
12,508,965 members (35,816 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL
This Query is Work : use for insert
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
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 15-Sep-12 1:04am
Updated 15-Sep-12 1:28am
Raje_12.9K
v2
Comments
tarun0702 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 ?
tarun0702 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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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,
  Permalink  
Comments
tarun0702 15-Sep-12 7:43am
   
Perfect Ans.

Thx a lot....:)
@amitgajjar 15-Sep-12 7:43am
   
Your welcome dear.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Finally. i got solution for this Problem.
problem is circular execute SP.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100