Hello, everyone
I'm new into databases. I have an Oracle insert sequence that I need to convert to SQL server
if anyone could help me to get this to work. I'm not sure if nextval is compatible with SQL Server.
Here is the code:
// original
insert into invoice
select inv_no_seq.nextval, company_id, trunc(sysdate),
trunc(sysdate) + 30, amount
from
(select co.company_id
,sum(a.amount_paid) amount
from company co, attendance a, student s
where s.student_id = a.student_id
and co.company_id = s.company_id
group by co.company_id);
// my changes
insert into invoice
select inv_no_seq.nextval, company_id, convert(datetime, convert(date,getdate())),
convert(datetime, convert(date,getdate())) + 30, amount
from
(select co.company_id
,sum(a.amount_paid) amount
from company co, attendance a, student s
where s.student_id = a.student_id
and co.company_id = s.company_id
group by co.company_id);
Thank you in advance.