t-sqlssms-2014

When using 'Replace' built in function in T-SQL within a Select Query, does the data on the table get modified?


I have the following query

SELECT  
    [DocID],
    [Docunum],
    [Comments] = REPLACE(REPLACE([Comments], CHAR(13), ''), CHAR(10), '')
FROM 
    [Billy].[dbo].[order]
WHERE
    DocDate = '2017-12-20 00:00:00.000'

I was wondering if the replace function, actually changes the value in the database? My concern is that this is ERP and I do not want referential integrity problems. I only want to eliminate the carriage separators from the NVARCHAR column to avoid spacing issues while pasting in Excel. I do not want any values changed in the database.

Any feedback would be appreciated. I have searched and did not find anything that answered this specifically. If I missed something please post link for reference if possible.


Solution

  • Actually here you are using replace in Select query so it will not affect your database it will only affect your result which is returned by this query, so here you are safe.