hi
below procedure is for update or insert.but everytime it inserts new row with previous row data and updated one not updating existing row.
ALTER PROCEDURE [dbo].[sp_WorkStatus] -- Add the parameters for the stored procedure here @ID int, @WalktestStatus nvarchar(50) ,@WalktestComments nvarchar (max) ,@InstallationStatus nvarchar(50) ,@InstallationComments nvarchar (max) ,@ppSatus nvarchar(50) ,@ppComments nvarchar (max) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here if exists (select * from WorkStatus where ID=@ID and WalktestStatus=@WalktestStatus and InstallationStatus=@InstallationStatus and ppSatus=@ppSatus) begin update WorkStatus set WalktestStatus=@WalktestStatus,WalktestComments=@WalktestComments,InstallationStatus=@InstallationStatus,InstallationComments=@InstallationComments,ppSatus=@ppSatus,ppComments=@ppComments where ID=@ID and WalktestStatus=@WalktestStatus and InstallationStatus=@InstallationStatus and ppSatus=@ppSatus end else BEGIN insert into WorkStatus(ID,WalktestStatus,WalktestComments,InstallationStatus,InstallationComments,ppSatus,ppComments) values (@ID,@WalktestStatus,@WalktestComments,@InstallationStatus,@InstallationComments,@ppSatus,@ppComments) End end
output:
ID walkteststatus walktestcomm instastatus instacomm postprocsta ppcoments
1 8 In Process in progress In Process in progress In Process in preogress 2 8 Complete Completed In Process in progress In Process in preogress 3 8 Complete Completed Complete not compled In Process in preogress 4 8 Complete Completed Complete not compled On Hold its on hold not working 5 8 Complete not complet Complete Complete its completed 6 8 On Hold Completed Complete Complete its completed