Create procedure sp_ConvProc2View
( @procName varchar(80),
@viewName varchar(80))
as
-- -------------------------------------------------------------
-- Procedure name: sp_ConvProc2View
-- Sp Author : Eli Leiba
-- Date 11-2005
-- Description : created a view with same result as the sp
-- the view can be SELECTed FROM
-- ------------------------------------------------------------
begin
declare @TSQLStmt varchar(500)
set nocount off
-- create the CREATE VIEW tSQL statement.
-- An OPENROWSET operator is used on the local server (. means local)
-- using SQLOLEDB provider along with a trusted connection (windows authentication)
-- SET FMTONLY off ensures that the results will be output (not just the metaData)
-- the EXEC storedProcedure finishes the OPENROWSET parameter.
set @TSQLStmt = 'CREATE VIEW ' + @viewName + ' AS SELECT * FROM ' +
'OPENROWSET ( ' + '''' + 'SQLOLEDB' + '''' + ',' +
'''' + 'SERVER=.;Trusted_Connection=yes' + '''' + ',' +
'''' + 'SET FMTONLY OFF EXEC ' + @procName + '''' + ')'
-- now , we dynamically execute the statement
exec (@TSQLStmt)
set nocount on
end
go
exec sp_ConvProc2View @procName = 'sp_who',
@viewName ='v$Session'
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
select * from v$session
![](http://i2.51cto.com/images/blog/201805/17/21ede5991cacfa4acb0dd9473edb45c6.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
ConvProc2View
转载文章标签 ConvProc2View 文章分类 SQL Server 数据库
上一篇:停机时受影响的作业
下一篇:克隆现有实例的登录名与密码
-
MySQL 给用户添加 ALTER VIEW 的权限
在某些情况下,需要为用户添加特定的权限,例如 ALTER VIEW 权限,以允许他们修改视图。
数据库 MySQL 数据 ALTER VIEW 视图 -
自定义初学2——扩展View
倘若我们需要的功能找不到对应的系统控件了,这时我们就只能自己绘制了。首先定义一个继承View的基类,然后重写View类的一个或多个方法
android开发 自定义 android 布局文件 ide -
Yii2 在view里加css
$this->registerCssFile("http://example.c
yii js css framework xml