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
 General SQL Server Forums
 New to SQL Server Programming
 store procedure to copy views results to a table

Author  Topic 

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-02-17 : 15:00:39
I am looking for an example of a store procedure that will run a existing view and copy the results to a table. Every time it runs the table needs to be truncated. Will run once a day.

My view is a follows
SELECT PClass
FROM mydatabase.dbo.ProductClassDes
WHERE (ProductClass <> '_RBS') AND (ProductClass <> '_EDT') AND (ProductClass <> '_BMS') AND (ProductClass <> '_PAZ') AND (ProductClass <> '_PBC')

View results need to be copied to a table tblCurrentProductClasses that will only contain one field PClass.

Any help appreciated.

Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2014-02-17 : 15:16:21
[code]
create procedure myProcedure as
begin
truncate table tblCurrentProductClasses

insert into tblCurrentProductClasses (PClass)
select PClass
from myView
end
go
[/code]

Be One with the Optimizer
TG
Go to Top of Page

Patyk
Yak Posting Veteran

74 Posts

Posted - 2014-02-17 : 16:01:34
thanks it works
Go to Top of Page
   

- Advertisement -