If row exists in table update else insert a new row
Posted on 2014-12-17
I have the following stored procedure:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER PROCEDURE [dbo].[InsertNewRow]
@StartDate DateTime = null
if @StartDate is null
set @StartDate = getdate()
EXEC CITYCRM_MSCRM.dbo.PortfolioHistory @EndDate = @StartDate
It adds a new row to the table.
Now the SP is going to be run more than once a day so I need to update the row if there is a row with the same date (first column in the row of the table), otherwise I need to do what the SP does currently.
Any help would be appreciated.