我有這樣一個存儲過程:不能夠採取特定的ID從自動從另一個表
ALTER procedure [dbo].[ParkingDeatailsReportnew]
@locid INTEGER, @startdate nvarchar(100),@enddate nvarchar(100)
as
begin
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT distinct ',' + QUOTENAME(Vtype) from VType_tbl FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,'')
set @query = 'SELECT Date, ' + @cols + ' from (select v.Vtype, convert(date, dtime) as Date
from Transaction_tbl t inner join VType_tbl v on t.vtid = v.vtid where dtime between ''' + @startdate + ''' and ''' + @enddate + '''and locid = ' + (select l.Locid from Location_tbl l)
+ ' ) d pivot (count(Vtype) for Vtype in (' + @cols + ') ) p '
execute(@query)
end
在執行此查詢我得到以下錯誤:
expects parameter '@locid', which was not supplied.i want to take all locid from my location table
請檢查你的標題這是沒有意義的。 –