Ibrahim Samed Aker
Ibrahim Samed Aker

Reputation: 45

SQL Server, how to call view in stored procedure?

I have a question for SQL Server Management Studio.

How can I call view in a stored procedure?

Upvotes: 1

Views: 10079

Answers (2)

usefulBee
usefulBee

Reputation: 9692

Question has 1000+ views

SELECT * FROM ViewName

Upvotes: 4

Alexey Sumin
Alexey Sumin

Reputation: 62

I really cant understand what you want to know or to do. This is useless code, but maybe it can be helpfull:

use [AdventureWorks2012]
GO
create view dbo.EMP
as
SELECT [BusinessEntityID]
      ,[NationalIDNumber]
      ,[LoginID]
      ,[OrganizationNode]
      ,[OrganizationLevel]
      ,[JobTitle]
      ,[BirthDate]
      ,[MaritalStatus]
      ,[Gender]
      ,[HireDate]
      ,[SalariedFlag]
      ,[VacationHours]
      ,[SickLeaveHours]
      ,[CurrentFlag]
      ,[rowguid]
      ,[ModifiedDate]
  FROM [HumanResources].[Employee]
  where jobtitle = N'Research and Development Manager'
  GO

  create procedure dbo.p_select_from_EMP_view
  as
  begin
  select * from dbo.EMP
  end
  GO

  exec dbo.p_select_from_EMP_view

Upvotes: 4

Related Questions