可以使用Openrowset,但Openrowset不支持参数话的语句,要实现参数只能在客户端程序中把要的最终语句拼接好传入。
测试语句如下:
use
tempdb
go
create proc p_test
as
begin
select 1 as a , 2 as b , 3 as c union
select 4 as a , 5 as b , 6 as c union
select 7 as a , 8 as b , 9 as c
end
go
select * from openrowset
( 'sqlOLEDB' , 'Server=.;Trusted_Connection=yes;DataBase=tempdb' ,
'exec p_test' ) where a <> 4
go
drop proc p_test
go
create proc p_test
as
begin
select 1 as a , 2 as b , 3 as c union
select 4 as a , 5 as b , 6 as c union
select 7 as a , 8 as b , 9 as c
end
go
select * from openrowset
( 'sqlOLEDB' , 'Server=.;Trusted_Connection=yes;DataBase=tempdb' ,
'exec p_test' ) where a <> 4
go
drop proc p_test
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。