Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 将参数传递给存储过程som检索数据_Sql Server_Tsql_Stored Procedures - Fatal编程技术网

Sql server 将参数传递给存储过程som检索数据

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

我有一个检索数据的存储过程,该过程获取2个参数作为字符串

每次都会使用新参数多次调用此过程

我只想调用该过程一次,并将所有参数作为参数列表发送

这就是我尝试过的

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”中访问它们