Nayan_07 Nayan_07 -4 years ago 83
SQL Question

How can I insert Data (Microsoft SQL) in the same table with same set of records but with different value

I have a table Employee :

enter image description here

Need to Insert Same Data with different "Dept" in the same Employee Table.

Answer Source

Make insert from select, something like this:

declare @MAX_ID int = (select MAX(EID) from Employee)
insert into Employee (EID, Ename, Country, Salary, Dept)    
select @MAX_ID + ROW_NUMBER() OVER (ORDER BY [Ename] ASC), Ename, Country, Salary, 'Recruitment'
from Employee
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download