I want to update table from another table data using stored procedure in SQL server. For example I have two table tbl_1 and tbl_2. I want to copy new insert data of tbl_1 to tbl_2.
my stored procedure as following
CREATE PROCEDURE [dbo].[CHECK_NEW]
AS
begin transaction
declare @tempId int
declare @tempName varchar
DECLARE c1 CURSOR FOR
SELECT kId, kName
FROM table1
OPEN c1
FETCH NEXT FROM c1
INTO @tempId, @tempName
WHILE @@FETCH_STATUS = 0
BEGIN
if (SELECT sId FROM table2) NOT IN(@tempId)
insert into table(sId, name) values(@tempId, @tempName)
END
please help me!
Thanks in advance
AVADHESH PATEL
09-May-2013