Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
EMPID Branch Dept
101 A1 101
102 A2 109
103 A3 110
104 A1 NULL
105 A2 89
106 A3 96

I hav Huge Data Like Above Table i need to updates all null values BY selecting max value from the table with out duplicates

EXMPLE: A1 max value is 101 then next null value should be 102 like That....
Posted

1 solution

TRY THIS SQLCOMMAND

SQL
update mytable set dept =(select max(dept) from mytable )+1 where ID= (SELECT MIN(ID) FROM MYTABLE WHERE DEPT IS NULL) AND dept is Null 

RUN IT IN A LOOP CONTAINING THE COUNT OF THE NULL VALUES.
 
Share this answer
 
Comments
abhilash yelmelwar 22-Oct-12 7:59am    
It's Just Incrementing the Next value...But I need Separate Increment for A1,A2,A3 By selecting Max value

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900