Создание процедуры хранения в транзакционном SQL
Create Procedure GetRangeFromTable
As
Begin
create table #Result(
code varchar(50),
num int
)
Declare
@code varchar(50),
@start int ,
@end int
DECLARE num_cursor CURSOR FOR Select * from Table1
OPEN num_cursor
FETCH NEXT FROM num_cursor
INTO @code, @start, @end
WHILE @@FETCH_STATUS = 0
BEGIN
While @start <= @end
Begin
Insert into #Result(code,num) Values (@code,@start)
Set @start= @start + 1
End
FETCH NEXT FROM num_cursor
INTO @code, @start, @end
END
Select * from #Result
CLOSE num_cursor
DEALLOCATE num_cursor
End