create procedure gw
(
@hotel varchar(200),
@roomtype varchar(30),
@datebegin smalldatetime,
@dateend smalldatetime
)
as
set nocount on
declare @sql varchar(max)
set @sql = 'select da_date from greatwolfcleanedup where location like ' + quotename('%' + @hotel + '%', '''') + ' and roomtype like ' + quotename('%' + @roomtype + '%', '''') + ' and da_date >= ''' + convert(varchar(25), @datebegin, 112) + ''' and da_date < ''' + convert(varchar(25), dateadd(day, 1, @dateend), 112) + ''' group by da_date order by da_date'
execute crosstab @sql,
'min(da_rate)',
'executiontime',
'greatwolfcleanedup'
E 12°55'05.25"
N 56°04'39.16"