declare @str varchar(4000)
set @str='select distinct substring(objectid,charindex('+'''-'''+',objectid)+1,
len(objectid) - charindex('+'''-'''+',objectid)) tm, tydm ,mc from
aa order by tydm'
--select @str
exec (@str)
set @str='select distinct substring(objectid,charindex('+'''-'''+',objectid)+1,
len(objectid) - charindex('+'''-'''+',objectid)) tm, tydm ,mc from
aa order by tydm'
--select @str
exec (@str)
set @str = 'select distinct substring(objectid,charindex(''-'',objectid)+1,len(objectid) - charindex(''-'',objectid))) tm, tydm ,mc from aa order by tydm'
exec(@str)