vendredi 11 décembre 2015

Give Id from the maximum value

I have a query like below,

Select max(Mkey) from p_leave_allocation

which gives me max(Mkey) as 1643.

Now I want to insert into another table say p_leave_allocation_11122015 whose mkey should start from 1644

what will be the query then ?

UPDATE

I will be inserting data like this

INSERT INTO p_leave_allocation_11122015(Mkey, Entry_Sr_no, Comp_mkey,FDepartment_Id,FModule_Id,Year, Emp_mkey, Emp_card_no, U_Datetime, Delete_Flag,Month12)SELECT Mkey,Entry_Sr_no, Comp_mkey,FDepartment_Id,FModule_Id,Year,Emp_mkey,Emp_card_no,U_Datetime,Delete_Flag,Month12FROM p_leave_allocation

I am using sql-server-2005

Aucun commentaire:

Enregistrer un commentaire