Goran Bibic

Goran Bibic

  • 481
  • 2.9k
  • 197.6k

Counter in SQL from C#

Nov 20 2019 4:32 AM
I try this
  1. <pre>declare @maxNo integer = 0 select @maxNo = isnull(max(redni_broj), 0) from [dbo].[prenosnica_roba] WHERE id_fakture=3;Set @maxNo=@maxNo+1;  
  2. INSERT into dbo.prenosnica_roba (redni_broj)  
  3.      SELECT  @maxNo  
  4.     FROM dbo.mp_racun_roba  


I have reslult
1
1
1
..

Need to have
1
2
3
..

Answers (5)