Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @groupCount bigint = 1;
- DECLARE @currentGroupId int;
- WHILE @groupCount <= (
- SELECT COUNT(*) FROM dbo.Группы
- );
- BEGIN
- DECLARE @groupId int;
- DECLARE @subjectId int;
- SET @currentGroupId = (
- SELECT Номер
- FROM dbo.Группы
- WHERE Номер = @groupCount
- );
- DECLARE @subjectCursor CURSOR FOR
- SELECT ID, ROW_NUMBER() OVER (ORDER BY ID) AS subjectRowNumber
- FROM dbo.Предметы;
- OPEN @subjectCursor;
- FETCH NEXT FROM @subjectCursor INTO @subjectId, @subjectRowNumber;
- WHILE @subjectRowNumber <= (
- SELECT MAX(ROW_NUMBER()) OVER (ORDER BY ID) AS maxRowNumber
- FROM dbo.Предметы
- );
- BEGIN
- INSERT INTO dbo.Изучение (
- Группа_Номер,
- ID_Предмета,
- Часы,
- Вид_аттестации
- )
- VALUES (
- @currentGroupId,
- @subjectId,
- 10,
- 'Экзамен'
- );
- FETCH NEXT FROM @subjectCursor INTO @subjectId, @subjectRowNumber;
- END;
- CLOSE @subjectCursor;
- SET @groupCount = @groupCount + 1;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement