0

I am trying to update the table based on the values passed. I need to check if the same row exists in the table. If it doesn't exist then insert the values into table. If exists the update the particular row of table.

Currently I have written the stored proc to directly enter the values. Any help?

Create proc [dbo].[SaveBudgetDetails] @Quarter nchar(10), @Year int, @LineID nvarchar(MAX), @Project nvarchar(MAX), @Budget decimal(18,0) AS BEGIN INSERT INTO [dbo].[BudgetDetails] ([Quarter] ,[Year] ,[LineID] ,[Project] ,[Budget]) VALUES ( @Quarter,@Year,@LineID,@Project,@Budget) END 
3
  • Another example Using MERGE in SQL Server 2012 to insert/update data Commented Jul 26, 2017 at 3:33
  • My question is about IF statements. Please check the edited question. It doesn't look like I need to use merge here Commented Jul 26, 2017 at 3:34
  • Merge is exactly used for that.. try reading those questions Commented Jul 26, 2017 at 3:35

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.