Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Monthly Inventory

Author  Topic 

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-19 : 12:53:59
I want to save a monthly Inventory but am not sure of the best way. Am I on the right track with this query?

////
v_num number;

begin

Select [type],[ORG], Count(type)as TypeCount FROM [Tesisdev].[dbo].[VOIPNumbers] group by [ORG],[TYPE] ORDER BY ORG;

if v_num = 0 then
insert into MonthInventory values (val1,val2,val3,val4);
commit;
else
raise_exception;
end if;
end;
///

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-19 : 13:01:42
sorry didnt get that
where did u get v_num etc from?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-19 : 13:10:44
Just trying to think of a way to put what the Select statement returns into the MonthlyInventory table. Just a guess at this point
Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-19 : 13:26:05
I got it, I hope that this will be correct;

INSERT INTO [Tesisdev].[dbo].[VOIPMonthlyInventory] ([TYPE],[ORG],[Quantity])
Select [type],[ORG], Count(type)as TypeCount FROM [Tesisdev].[dbo].[VOIPNumbers] group by [ORG],[TYPE] ORDER BY ORG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-20 : 02:00:28
yep this looks fine.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -