Skip to content

Instantly share code, notes, and snippets.

@sixfeetover
Last active December 21, 2015 03:39
Show Gist options
  • Save sixfeetover/6244243 to your computer and use it in GitHub Desktop.
Save sixfeetover/6244243 to your computer and use it in GitHub Desktop.
Pass table variable as a procedure variable in SQL Server
create type GKCTable as table (
id int,
description varchar(255)
)
go
create procedure dbo.PrintGKC(@gkc_table GKCTable readonly)
as
select *
from @gkc_table
go
declare @grades GKCTable
insert @grades(id, description)
values (0, 'None'),
(1, 'First Grade')
exec PrintGKC @grades
drop procedure dbo.PrintGKC
drop type GKCTable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment