nischal problem solving try
select * from legends
TRUNCATE table legends
use myluckycharmshobhana
Begin TRANSACTION
begin TRY
Declare
@EmpName VARCHAR(20),
@Designation varchar(20),
@status varchar(30)
declare usevibura cursor for
select EmpName,DesignationId from Employee where DepartmentId='software'
and EmpId in ('11004','11002','11003','11014')
open usevibura
fetch next from usevibura into @EmpName,@Designation
while (@@FETCH_STATUS=0)
begin
select @EmpName=EmpName,@Designation=DesignationId from Employee where DepartmentId='software'
and EmpId in ('11004','11002','11003','11014')
if @Designation='Programmer'
begin
set @status='Target Destroyed'
end
insert into legends select @EmpName,@Designation,@status
fetch next from usevibura into @EmpName,@Designation
end
close usevibura
deallocate usevibura
COMMIT
End TRY
begin CATCH
if @@TRANCOUNT>0
ROLLBACK TRANSACTION
end CATCH
Comments
Post a Comment