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
 Transact-SQL (2000)
 Create view from stored procedure

Author  Topic 

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-05-04 : 01:37:31
First is it possible to create a view from stored procedure?

If it is possible how can I create it


Create View View1 AS
usp_dts_tempexport

Create View View1 As
Exec usp_dts_tempexport


usp_dts_tempexport is a stored proc which looks something like this

select col1,col2,col3 from tbla
union all
select col1,col2,col3 from tblb
union all
select col1,col2,col3 from tblb


The other option I see is to store these datas in a temp table and drop the temptable at the end of process. Any other suggesstions?

How does a #temptable and temptable differs?



Karunakaran
___________
It's better to be loved and lost, than ever to be loved...

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-05-04 : 04:42:56
you can't have a sproc in a view use either one or the other.
and why do you want to do this?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-05-04 : 09:26:20
The reason is very simple, I need a total count of the records from the view.

Karunakaran
___________
It's better to be loved and lost, than ever to be loved...
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-05-04 : 09:28:36
select count(*) from MyView ??

Go with the flow & have fun! Else fight the flow
Go to Top of Page

karuna
Aged Yak Warrior

582 Posts

Posted - 2005-05-04 : 12:10:37
quote:
Originally posted by spirit1

select count(*) from MyView ??
Go with the flow & have fun! Else fight the flow



This is possible, If I can create a view of my stored proc.
This stored proc is around 40 lines I use this inside dts
so I dont want to have all 40 lines inside a execute sql task.

Karunakaran
___________
It's better to be loved and lost, than ever to be loved...
Go to Top of Page
   

- Advertisement -