Insert auto Number in SQLSERVER

2
22

To insert unique serial numeric values to an SQL table usually DBAs rely on procs with loops and inside loop an incrementing variable substitutes numeric values

this may query time out., will consume mush significant time and may cause intermediate termination

to resolve this issue in SQL Server us the following query

suppose there is one table called customers and we need to back it up to  table customer_backup

insert into customers_backup
select cust_name,join_date,row_number() over (order by join_date)  from customers

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here