multiparametr identifire error showing while executing stored peocedure
i have a stored procedure like this: I have a stored procedure like this:
ALTER PROCEDURE [dbo].[ParkingDeatailsReportnew]
@startdate NVARCHAR(100),
@enddate NVARCHAR(100)AS BEGINDECLARE @cols AS NVARCHAR(MAX) , @query
AS NVARCHAR(MAX)
SELECT @cols = STUFF(( SELECT DISTINCT ',' + QUOTENAME(Vtype)
FROM dbo.VType_tbl FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'),
1, 1, '')
SET @query =
'SELECT LocName,Date, ' + @cols + '
from (
select l.LocName,v.Vtype, convert(date, dtime) as Date
from Transaction_tbl t
join VType_tbl v on t.vtid = v.vtid
where dtime between ''' + @startdate + ''' and ''' + @enddate + '''
and locid IN (SELECT l.Locid FROM dbo.Location_tbl l)
) d pivot ( count(Vtype) for Vtype in (' + @cols + ') ) p ' EXEC
sys.sp_executesql @query
END while executin i am getting error like this:The multi-part identifier
"l.LocName" could not be bound. how i can resolve this issue
No comments:
Post a Comment