Sql server 将参数传递给存储过程som检索数据
我有一个检索数据的存储过程,该过程获取2个参数作为字符串 每次都会使用新参数多次调用此过程 我只想调用该过程一次,并将所有参数作为参数列表发送 这就是我尝试过的Sql server 将参数传递给存储过程som检索数据,sql-server,tsql,stored-procedures,Sql Server,Tsql,Stored Procedures,我有一个检索数据的存储过程,该过程获取2个参数作为字符串 每次都会使用新参数多次调用此过程 我只想调用该过程一次,并将所有参数作为参数列表发送 这就是我尝试过的 create type dbo.adressAndCity as table ( [adress] string, [city] string ) go create procedure dbo.selectItems ( @Items adressAndCity readonly ) as begin
create type dbo.adressAndCity as table
(
[adress] string,
[city] string
)
go
create procedure dbo.selectItems
(
@Items adressAndCity readonly
)
as
begin
select *
from dbo.testTable
// the syntax below is nOt correct
where adress = (@Items.adress) And city = (@Items. city)
end
如何访问参数表中的值 我相信您正在寻找一个
加入
:
create procedure dbo.selectItems
(
@Items addressAndCity readonly
)
as
begin
select T.* from dbo.testTable T
INNER JOIN @Items I
ON T.address = i.address)
And T.city = I.city)
end
请注意,我已经纠正了您拼写错误的
地址
这是用于哪个RDBMS的?请添加一个标记以指定您是否正在使用mysql
,postgresql
,sqlserver
,oracle
或db2
-或其他完全不同的东西。根据使用的语法添加了sql server
和tsql
标记。访问表参数中的值的方式与访问表中的值的方式相同。@TabAlleman示例?如何在“where station”中访问它们