[Solved] I need to convert a Postgres specific query to SQL Server (T-SQL)


On SQL-Server use CHARINDEX

CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] )

DECLARE @CAMPO30 varchar(64) = '2,663.25';

SELECT CASE WHEN CHARINDEX('.', @CAMPO30) > 1
            THEN CAST(REPLACE(REPLACE(@CAMPO30,'.',''),',','.') AS FLOAT)
            ELSE CAST(REPLACE(@CAMPO30,',','.') AS FLOAT)
       END AS CAMPO30
GO

| CAMPO30 |
| ------: |
| 2.66325 |

dbfiddle here

1

solved I need to convert a Postgres specific query to SQL Server (T-SQL)