June 22, 2011 at 4:57 am
declare @report_instance nvarchar(50)
select @report_instance =
case
when @@servername like '%HQ04%' then 'HQ_REPORT'
when @@servername like '%INDBA02%' then 'IN_REPORT'
end
select top 1 * from (select @report_instance).master.dbo.sysobjects
Msg 102, Level 15, State 1, Line 13
Incorrect syntax near '.'.
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
June 22, 2011 at 5:16 am
You can't parameterise a schema as such.You need to create a dynamic sql string and execute that.
June 22, 2011 at 10:46 am
declare @report_instance nvarchar(50)
select @report_instance =
case
when @@servername like '%HQ04%' then 'HQ_REPORT'
when @@servername like '%INDBA02%' then 'IN_REPORT'
end
select @report_instance
Declaring a variable doesn't make an object.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply