--创建student表
create table student(
id int ,
name varchar(30),
age int
)
insert into student values(1,'张三',22);
insert into student values(2,'李四',22);
insert into student values(3,'王五',22);
create proc wx$opencard(@p_appid varchar(20),@p_param varchar(20))
as
select * from student where id = @p_appid and age = @p_param;
go
--通过openrowset在函数中调用存储过程
create function test()
returns table
as
return
SELECT * FROM OPENROWSET(
'SQLOLEDB.1',
'server=SERVER-PC\SQLEXPRESS;uid=root;pwd=root',
'exec wx$opencard 1,22'
)
go
开启openrowset方法
sp_configure 'show advanced option',1;
GO
RECONFIGURE
sp_configure 'Ad Hoc Distributed Queries',1;
GO
RECONFIGURE