Insert and Update

Sep 23 2015 5:15 AM
Hi,
 
Iam writing the stored procedure ,I want to insert and update the values for the one table in one qurey  .I want to insert team name if teamid is not specified, if teamid is specified  then i will update the teamname based on id.But the problem is i didn't get any issues i will executed successfully.
issue is i'm getting the insert value but the value is not updated .
 
Here is my query..
 
 
ALTER PROCEDURE UspInsertUpdateTeam
(
@TeamID INT,
@TeamName NVARCHAR(50)
)
AS
BEGIN
SET NOCOUNT ON;
--IF EXISTS (SELECT TeamName FROM Team )
--IF EXISTS (SELECT TeamName=NULL FROM Team)
IF @TeamName=''
insert into Team(TeamName)values(@TeamName);
ELSE IF @TeamName='TeamName'
UPDATE Team set TeamName=@TeamName
where TeamID=@TeamID;
END
 
 
If anyone please help me.
 
Thanks,
Prathysha 
 

Answers (8)