declare @year nvarchar(4), @dbname nvarchar(8)
select @year = YEAR(getdate())
set @dbname = 'DB'+@year
set @sqlcmd = 'declare @MaxUID varchar(17) select @MaxUID = MAX(UIDnum) from '+@dbname+'.ARCHDATA.ARCHIVE'
execute sp_executesql @sqlcmd
print @sqlcmd
|