SQL Server,如何在存储过程中调用视图?

时间:2017-05-17 10:58:10

标签: sql-server stored-procedures

我对SQL Server Management Studio有疑问。

如何在存储过程中调用视图?

2 个答案:

答案 0 :(得分:3)

我真的不明白你想知道或想做什么。 这是无用的代码,但它可能有用:

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

答案 1 :(得分:1)

问题有1000多个观点

SELECT * FROM ViewName