I have a view from which I want to remove a specific character in one of the columns. Specifically the character 'B' from the 'Fund' column below.
I tried using the following version of TRIM
SELECT
TRIM('B' FROM [Port_Ticker]) as "Fund"
,[BENCH_Ticker] as "Index ID"
,format(cast([VALUE_DATE] as Date),'dd/MM/yyyy') as "Updat"
,([Port_Risk_Contrib] / 10000000) as "StDev Fund"
,([Active_risk_contrib] / 10000000) as "TE"
,([BENCH_RISK_CONTRIB] / 100) as "StDev BM"
FROM [DM_PORTFOLIO_ANALYSIS].[basedata].[PortfolioRiskFigures]
where [BLOCK_FACTOR] = 'Total'
and [Port_ticker] =
'B1023'
order by [VALUE_DATE] asc
Which gives me the error
Msg 156, Level 15, State 1, Line 3. Incorrect syntax near the keyword 'FROM'.

FORMAT, it's an awfully slow function. You would be far better off usingCONVERTand a style code. Soformat(cast([VALUE_DATE] as Date),'dd/MM/yyyy')could be change toCONVERT(varchar(10),[VALUE_DATE],103)(assuming thatVALUE_DATEis adatetimedatatype, which I see no reason why it would be as it's storing a date. :) )TRIMis available since SQL Server 2017. So your version doesn't supportTRIM: learn.microsoft.com/en-us/sql/t-sql/functions/trim-transact-sqlFORMATis compared toCONVERT: db<>fiddle