ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Update multiple records in table using Stored Procedure in SQL Server<p>Hi <a class="username" rel="Waghmare"> Waghmare</a>,</p> <p>Refer below sample query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span> </p> <pre class="brush: sql">CREATE TABLE MainTable(ID INT, EndDate DATETIME, ReviewDate DATETIME) INSERT INTO MainTable VALUES(1,&#39;2019-06-15&#39;,&#39;2019-06-18&#39;) INSERT INTO MainTable VALUES(2,&#39;2019-06-19&#39;,&#39;2019-06-25&#39;) INSERT INTO MainTable VALUES(3,&#39;2019-06-10&#39;,&#39;2019-06-14&#39;) INSERT INTO MainTable VALUES(4,&#39;2019-06-05&#39;,&#39;2019-06-09&#39;) INSERT INTO MainTable VALUES(5,&#39;2019-07-01&#39;,&#39;2019-07-09&#39;) CREATE TABLE #HistoryTable(ID INT, EndDate DATETIME, ReviewDate DATETIME) CREATE PROCEDURE InsertUpdateTable AS BEGIN DECLARE @CurrentDate DATETIME SET @CurrentDate = (SELECT GETDATE()) IF EXISTS(SELECT * FROM MainTable WHERE @CurrentDate BETWEEN EndDate AND ReviewDate) BEGIN INSERT INTO HistoryTable(Id,EndDate,ReviewDate) SELECT * FROM MainTable WHERE @CurrentDate BETWEEN EndDate AND ReviewDate UPDATE MainTable SET EndDate = @CurrentDate SELECT * FROM MainTable SELECT * FROM HistoryTable END END</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/677438/Update-multiple-records-in-table-using-Stored-Procedure-in-SQL-Server/https://www.aspforums.net:443/Threads/677438/Update-multiple-records-in-table-using-Stored-Procedure-in-SQL-Server/Mon, 01 Jul 2019 07:01:26 GMT