Sqlserver in 实现 参数化查询 XML类型解决方案
程序员文章站
2022-04-20 13:44:58
...
1:如果 参数 是int 类型 : declare @a xml set @a=' rowid1/id/row rowid5/id/row rowid4/id/row rowid3/id/row rowid2/id/row' select * from product where id in ( select d.x.value('./id[1]','int') from @a.nodes('/*') as d(x)) 2:如果 参数 是var
1:如果参数是int类型:
declare @a xml
set @a='
select * from product where id in (
select d.x.value('./id[1]','int') from @a.nodes('/*') as d(x))
2:如果参数是varchar类型:
declare @a xml
set @a='
select * from product where pname in (
select d.x.value('./name[1]','varchar(100)') from @a.nodes('/*') as d(x))
以第一个为例写的C#简单方法
public DataSet GetData(Listint