Row number creation
Hi,
I have a table like below
create table ##Test (Inv nvarchar(5), InvDate date)
insert into ##Test values (‘1001′,’2024-01-01’)
insert into ##Test values (‘1001′,’2024-01-01’)
insert into ##Test values (‘1001′,’2024-01-01’)
insert into ##Test values (‘1001′,’2024-01-02’)
insert into ##Test values (‘1001′,’2024-01-02’)
insert into ##Test values (‘1001′,’2024-01-03’)
select * from ##Test
drop table ##Test
I need a result set like below. how to achieve that
create table ##Result (RowNo int,Inv nvarchar(5), InvDate date)
insert into ##Result values (1, ‘1001’,’2024-01-01′)
insert into ##Result values (1, ‘1001’,’2024-01-01′)
insert into ##Result values (1, ‘1001’,’2024-01-01′)
insert into ##Result values (2, ‘1001’,’2024-01-02′)
insert into ##Result values (2, ‘1001’,’2024-01-02′)
insert into ##Result values (3, ‘1001’,’2024-01-03′)
select * from ##Result
drop table ##Result
Thanks
Hi, I have a table like below create table ##Test (Inv nvarchar(5), InvDate date)insert into ##Test values (‘1001′,’2024-01-01’)insert into ##Test values (‘1001′,’2024-01-01’)insert into ##Test values (‘1001′,’2024-01-01’)insert into ##Test values (‘1001′,’2024-01-02’)insert into ##Test values (‘1001′,’2024-01-02’)insert into ##Test values (‘1001′,’2024-01-03’)select * from ##Testdrop table ##Test I need a result set like below. how to achieve thatcreate table ##Result (RowNo int,Inv nvarchar(5), InvDate date)insert into ##Result values (1, ‘1001’,’2024-01-01′)insert into ##Result values (1, ‘1001’,’2024-01-01′)insert into ##Result values (1, ‘1001’,’2024-01-01′)insert into ##Result values (2, ‘1001’,’2024-01-02′)insert into ##Result values (2, ‘1001’,’2024-01-02′)insert into ##Result values (3, ‘1001’,’2024-01-03′)select * from ##Resultdrop table ##Result Thanks Read More