I have the following T-SQL in MSSQL,
Declare @S table(StartAc bigint)
Declare @E table(EndAc bigint)
Declare @B table(BNum varchar(20))
Select StartAc=[Start] from [dbo].[CFC]
Select EndAc=[EndCode] from [dbo].[CFC]
Select ENum=[ENum] from [dbo].[CFC]
;with CFile as (
Select StartAc as AcNum
from @S
union all
Select AcNum+1
from CFile
where AcNum+1 <=EndAc
)
Insert into dbo.list
Select ENum,*
from CFile Option(Maxrecursion 32676)
Actually I have a table with EmployeeID,StartingNumber and EndingNumber (lets say Ranges),I need to generate all Numbers between those Starting and EndingNumbers for all Employees.I created using Single Employee but not working for all Employees.