朱 ろ碁ゼ 蟆曙 襷れ. 伎螻 螳.
use tempdb
go
--drop table source_table
create table source_table (
id varchar(10)
, pw varchar(10)
);
--drop table target_table
create table target_table (
id varchar(10)
, pw varchar(10)
);
insert source_table values
('dwa', '1234')
, ('yasi', '4567')
, ('lk', 'lk123') --new syntax, T-SQL Row Constructors
go
襷り, 襦 Row Set 襷り覲襦 覦 . 襯 れ 襷り覲襦 '1,2,3,4' 螳 蟲覿襯 螳讌 覓語伎 燕 企 襦 襷れ朱 SQL Server 2008 覦 覃 .
create type id as table --new syntax, Table Value Type
(
id varchar(10) null
);
go
create proc table_value_param_test
@table id readonly
as
begin
declare @i int = 10; --new syntax
select * from source_table
where id in (select id from @table)
end
go
declare @param as id;
insert @param(id) values('dwa'), ('yasi');
exec table_value_param_test @param;
/*
id pw
---------- ----------
dwa 1234
yasi 4567
*/