SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Adding Parameter after dynamic query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 03/25/2013 :  15:20:37  Show Profile  Reply with Quote

I am getting a syntax error when trying to add a parameter after my dynamic sql code, within the query designer in ssrs.

the syntax error is on the '+' before my @ReportList. how do I fix this syntax error?

my code is:

('select M.MDSITENAME, P.lastname +'', ''+ p.firstname +'' (''+p.MedRecNumber+'')'' as PatientName , c.entrydate,
tr.TransactionTypeabbreviation+'' ''+cast(c.TransactionAmount as varchar) as TransType, f.billnum,
f.commonName+'' ''+f.strength+'' ''+'' ''+f.uom+'' ''+f.form as DrugName, o.lastname +'', ''+ o.firstname as OperatorName, w.LastName +'', ''+w.FirstName AS WitnessName
from T_CHARGE c
inner join T_PATIENT p on p.PatientID = c.patientid and p.siteid = c.siteid
inner join T_Operator o on o.operatorid = c.OperatorID and o.siteid = c.siteid
left join T_OPERATOR AS w ON c.WitnessID = w.OperatorID and c.siteid = w.siteid
inner join T_FORMULARY f on f.formularyid = c.formularyid and f.siteid = c.siteid
inner join T_TRANSACTION_TYPE tr on tr.TransactionTypeID = c.TransactionType
inner join T_STATION s on s.stationid = c.stationid and s.siteid = c.siteid
inner join t_mdsite m on m.mdsiteid = c.siteid
where c.entrydate >= '''+@StartDate+''' and c.entrydate < dateadd(day,1,'''+@EndDate+'''
AND m.activesite = 1 and ') +@ReportList

Very Important crosS Applying yaK Herder

52325 Posts

Posted - 03/26/2013 :  14:41:46  Show Profile  Reply with Quote
whats command type selected? you dont need dynamic sql. just choose type of text and use above query after removing inner 's

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000