Avatar of deanmachine333
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Use parameter value as database in from clause?

Hello guys,

I have to create a report to be able to use a parameter value in the from clause , the parameter is a database followed by table name eg in code section.

@dbase varchar(100)

,[DET_NOMINALDR] as [Nominal Code]
,[DET_DATE] as [Date]
,[DET_PERIODNUMBR] as [Period]
,[DET_YEAR] as [Year]
,[DET_DESCRIPTION] as [Narrative]
,[DET_NETT] as [D/C]

FROM @dbase.[dbo].[SL_PL_NL_DETAIL]
WHERE [Nominal Code] = 'DT10000'
  and [Date] = '2011-08-01'

Open in new window

Microsoft SQL ServerMicrosoft SQL Server 2008SSRS

Avatar of undefined
Last Comment

8/22/2022 - Mon