带参数的OPENQUERY查询的写法

--带参数的OPENQUERY查询
exec('

select AREANO, AREANAME from OPENQUERY(GSW, ''select AREANO, AREANAME from GSW.V_AREAINFOMATION 
where AREANO like ''''%'+@sqlStr+'%'''' or AREANAME like ''''%'+@sqlStr+'%''''  '')

')
print('

select AREANO, AREANAME from OPENQUERY(GSW, ''select AREANO, AREANAME from GSW.V_AREAINFOMATION 
where AREANO like ''''%'+@sqlStr+'%'''' or AREANAME like ''''%'+@sqlStr+'%''''  '')

')


/*
--打印结果
select AREANO, AREANAME from OPENQUERY(GSW, 'select AREANO, AREANAME from GSW.V_AREAINFOMATION 
where AREANO like ''%河北%'' or AREANAME like ''%河北%''  ')
*/

你可能感兴趣的:(SQL,Server数据库)