Skip to content
Advertisement

How can i duplicate records with T-SQL and keep track of the progressive number?

How can I duplicate the records of table1 and store them in table2 along with the progressive number calculated from startnum and endnum? Thanks

the first row must be duplicated in 4 records i.e num: 80,81,82,83

Result:

Advertisement

Answer

Without recursion:

You can use any other table with enough rows instead of sys.all_columns

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement