New feature! Upgrade and increase expert visibility of your issues with Priority Questions.
if OBJECT_ID('tempdb..##tmpUserDBase') IS NOT NULL begin drop table ##tmpUserDBase end declare @dbase varchar(150) = 'testdbase' declare @ncode varchar(25) = 'DT10150' declare @period varchar(10) = 8 declare @year varchar(10) = 'C' declare @STR varchar(max) SET @STR =' SELECT '''+@dbase+''' as [DBASE] ,[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 [DET_NOMINALDR] = ''@ncode'' and [DET_PERIODNUMBR] = ''@period'' and [DET_YEAR] = ''@year'' ' create table ##tmpUserDBase (DBASE varchar(100) ,[Nominal Code] varchar(100) ,[Date] date ,[Period] varchar(100) ,[Year] varchar(1) ,[Narrative] varchar(250) ,[D/C] float) insert into ##tmpUserDBase exec (@STR) select * from ##tmpUserDBase
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.