Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
jpersQ
New Member

SQL REPLACE function broken on Fabric Lakehouse SQL Endpoint

REPLACE is not replacing values in some instances:

 

 

REPLACE.png

1 ACCEPTED SOLUTION
Ray_Minds
Continued Contributor
Continued Contributor

Hi @jpersQ
 To remove all carriage return (CHAR(13)) and line feed (CHAR(10)) characters from your SQL Server data, you can utilize the REPLACE function as follows:

SELECT [Id],
       [Description],
       REPLACE(
           REPLACE(
               REPLACE(Description, CHAR(13) + CHAR(10), ''),
               CHAR(13), ''),                                
           CHAR(10), '') AS Cleaned_Description              
FROM bronze_Salesforce_event;



Ray_Minds_0-1741082177481.jpg

 

Best regards,
Ray Minds
http://www.rayminds.com
https://www.linkedin.com/company/rayminds/

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



View solution in original post

11 REPLIES 11
Ray_Minds
Continued Contributor
Continued Contributor

Hi @jpersQ
 To remove all carriage return (CHAR(13)) and line feed (CHAR(10)) characters from your SQL Server data, you can utilize the REPLACE function as follows:

SELECT [Id],
       [Description],
       REPLACE(
           REPLACE(
               REPLACE(Description, CHAR(13) + CHAR(10), ''),
               CHAR(13), ''),                                
           CHAR(10), '') AS Cleaned_Description              
FROM bronze_Salesforce_event;



Ray_Minds_0-1741082177481.jpg

 

Best regards,
Ray Minds
http://www.rayminds.com
https://www.linkedin.com/company/rayminds/

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



v-mdharahman
Community Support
Community Support

Hi @jpersQ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.


Thank you.

v-mdharahman
Community Support
Community Support

Hi @jpersQ,

As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.


If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.

v-mdharahman
Community Support
Community Support

Hi @jpersQ,

Thanks for reaching out to the Microsoft fabric community forum.

 

It looks like you are facing issue with REPLACE function, which is not working properly in few instances. As @nilendraFabric responded to your query, were you abke to go through his responses. If you are able to solve the issue, please mark the helpful reply as solution.

 

I would also take a moment to thank @nilendraFabric, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

Hi @jpersQ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

nilendraFabric
Community Champion
Community Champion

Hello @jpersQ 

 

Could you please share query and example 

The query is as above: 

SELECT ASCII(SUBSTRING(REPLACE(REPLACE(CAST([Description] AS NVARCHAR(4000)), NCHAR(13), ''), NCHAR(10), ''), 14, 1)) AS D
FROM [dbo].[bronze_Salesforce__event]
where Id= '00UVS000003zCXI2A2'

I'm having a hard time getting an anyonymized data example since the issue is finicky.

 

SELECT ASCII(SUBSTRING(REPLACE(REPLACE(CAST([Description] AS VARCHAR(8000)), CHAR(13), ''), CHAR(10), ''), 14, 1)) AS D
FROM [dbo].[bronze_Salesforce__event]
WHERE Id = '00UVS000003zCXI2A2'

 

 

try this once 

Already tried, it doesn't fix the issue.  Neither does casting as NVARCHAR, or casting as NVARCHAR plus using NCHAR(13) and NCHAR(10).


REPLACE for CRLF or CHAR(10), CHAR(13) is definetly broken. I tested using SSMS and Browser SQL analytics endpoint.
I needed to create the view in order to use the transformed data but failed. 

I thought of using the a custom scaler function where I was successfully replacing them by looping through characters.

Of course, scaler functions are not allowed end up using CTE. Too much work around in order to fix small thing.

 

 

Ok. Try recreate the table using explicit `VARCHAR` column definitions in Spark (e.g., `VARCHAR(40)` instead of generic `STRING`)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.