Unable to use undeclared variable DECLARE @LINKEDSERVER VARCHAR(20)= 'LS_CMT';
        DECLARE @ODS_DBNAME VARCHAR(20)= '';
        SET @ODS_DBNAME = DB_NAME();
        DECLARE @OCS_DBNAME VARCHAR(20)= '';
        SET @OCS_DBNAME = 'CMT' + SUBSTRING(@ODS_DBNAME, CHARINDEX('_', @ODS_DBNAME), LEN(@ODS_DBNAME))
SELECT * FROM @ODS_DBNAME.[dbo].CLI_LOCATIONS
You can use EXEC for that purpose
DECLARE @LINKEDSERVER VARCHAR(20)= 'LS_CMT'; 
DECLARE @ODS_DBNAME VARCHAR(20)= ''; 
SET @ODS_DBNAME = DB_NAME(); 
DECLARE @OCS_DBNAME VARCHAR(20)= ''; 
SET @OCS_DBNAME = 'CMT'
                  + SUBSTRING(@ODS_DBNAME, CHARINDEX('_', @ODS_DBNAME), LEN(@ODS_DBNAME)) ;
 EXEC('SELECT * FROM ' + @ODS_DBNAME + '.[dbo].CLI_LOCATIONS');