sql - Add different number for every row in a table -


i have flat table fake customer information (name, address, gender,...). added column flat table called customer_id of values null. i'm trying add different id every customer i'm not sure how achieve that. i've done far, don't have primary key table since want customer_id primary key

alter procedure [dbo].[add_id] begin     declare @customer_id int     declare cursor1 cursor         select         customer_id             flat_customer     open cursor1     fetch next cursor1 @customer_id     while(@@fetch_status = 0)     begin         if(@customer_id null)         begin             exec get_next_id_by_name 'customer', @customer_id output         end         fetch next cursor1 @customer_id     end end 

i'm still beginning in sql i'm not sure how parse trough row row

just this:

declare @i int = 1; update flat_customer set customer_id = @i,     @i=@i+1; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -