How do i compare the values of Two Cursors and do update operation if the values matches.I am using Joins(Join query) in both the cursors.Please provide a appropriate solution(Working procedure) for this issue. Thanks in advance
vasanth svs
-- First Cursor
-- DECLARE two variablesDECLARE @fName1 varchar(50), @lName1 varchar(50)-- Declare cursorDECLARE cursor1 CURSOR FOR Select firstName, lastName FROM myTable1 INNER JOIN mytable2-- open the cursorOPEN cursor1-- Fetch a row from cursor into two variablesFETCH NEXT FROM cursor1 INTO @fName1, @lName1
-- second cursor
-- DECLARE two variablesDECLARE @fName2 varchar(50), @lName2 varchar(50)-- Declare cursorDECLARE cursor2 CURSOR FOR Select firstName, lastName FROM myTable3 INNER JOIN mytable4-- open the cursorOPEN cursor2-- Fetch a row from cursor into two variablesFETCH NEXT FROM cursor2 INTO @fName2, @lName2
-- Now compare the @fName1 wth fName2 and then lName1 with lName2 using IF
IF @fName1 = @fName2 AND @lName = @lName
-- DO UR TASK OF UPDATE
Hope it is helpful to u though m late