忍者ブログ

技術メモ

Home > ブログ > > [PR] Home > ブログ > Database > Sqlserver ユーザ定義テーブル型

Sqlserver ユーザ定義テーブル型


--テーブルを宣言
create table nhamtbl1 (id varchar(10))
insert into nhamtbl1 values('aaa')

--ユーザ定義テーブル型を宣言
CREATE TYPE sampletabletype
  AS TABLE ( id varchar(10) )
go

--テーブル値パラメータを持つプロシージャを宣言
alter procedure sampleproc( @sampletable sampletabletype readonly)
as
 declare @id varchar(10)
 select @id = id from @sampletable
 print @id
go

--プロシージャ呼び出し
declare @sampletable sampletabletype
insert into @sampletable values('bbb')
exec sampleproc @sampletable

PR

Comment0 Comment

Comment Form

  • お名前name
  • タイトルtitle
  • メールアドレスmail address
  • URLurl
  • コメントcomment
  • パスワードpassword

PAGE TOP