INSERT INTO studenci (id, Imie, Nazwisko, Pesel) VALUES (1, 'Jan', 'Kowalski', '90090512345'), (2, 'Anna', 'Nowak', '93071012345'), (3, 'Piotr', 'ZieliƄski', '92021512345'); select * from studenci; select * from studenci2; create procedure [dbo].[wstaw_wiek] as begin declare @student_id int, @Imie varchar(20) not null, @Nazwisko varchar(25) not null, @Pesel varchar(11) not null, @Wiek int not null; declare StudentCursor cursor for select id,Imie,Nazwisko,Pesel from studenci; open StudentCursor; fetch next from StudentCursor into @student_id, @Imie,@Nazwisko,@Pesel; while @@FETCH_STATUS = 0 begin set @Wiek = datediff(year,substring(@Pesel,1,6)getdate()); insert into studenci2(id_studenta,wiek) values(@student_id,@wiek); fetch next from StudentCursor into @student_id,@Imie,@Nazwisko,@Pesel; end; close StudentCursor; deallocate StudentCursor; end; execute wstaw_wiek;