sql server 2008 - How to pass more than one values as parameter to sql statement? -
i have 1 big sql query , want pull out data using query
declare @period varchar(10) = 'mtd' declare @date datetime = '2011-08-31'
and have big select statement
i'm passing above parameters , executes output.
now have 10 different dates need pass here each time see result.
how can pass date above parameter declare @date datetime
how can hard code ?
so desired output selected dates, give me hint @ least 3 dates ?
use table-valued parameter. first, create type:
create type dbo.dates table(d date);
now stored procedure can take type parameter:
create procedure dbo.whatever @d dbo.dates readonly begin set nocount on; select t.columns dbo.tablename t inner join @d d on t.[date] = d.d; end go
then application can pass parameter in datatable
, example.
Comments
Post a Comment