i try to build a store procedure who insert data to a table, after it run, the table is empty.
this is the code:
CREATE TABLE invoices
(invoiceNo int,
invoiceDate date,
invoiceTotal int,
invoiceType char(1))
alter PROCEDURE Invoices_AGG
@year int
AS
select
(case when MONTH(invoiceDate) >9 then concat('01','/',MONTH(invoiceDate),'/',year(invoiceDate)) else concat('01','/0',MONTH(invoiceDate),'/',year(invoiceDate)) end) as DateID,
SUM(case when invoiceType = 'B' then invoiceTotal else 0 end) as Total_Incomes_TypeB,
SUM(case when invoiceType = 'I' then invoiceTotal else 0 end) as Total_Incomes_TypeI
into FACT_Invoices_AGG
from invoices
where year(invoiceDate)=@year
group by (case when MONTH(invoiceDate) >9 then concat('01','/',MONTH(invoiceDate),'/',year(invoiceDate)) else concat('01','/0',MONTH(invoiceDate),'/',year(invoiceDate)) end);
exec Invoices_AGG 2013
thank you