praveen subbu
praveen subbu

Reputation: 31

How to change datatype using replace function in SQL Server

select
    replace(Street, char(10), '')
from streettable

Have explored the syntax of replace function ...but how does this piece of code work?

Upvotes: 0

Views: 170

Answers (1)

Giorgi Nakeuri
Giorgi Nakeuri

Reputation: 35780

The sample code doesn't change datatype. char(10) is line feed and the code just replaces line feeds with empty symbol in street column(not in table, but on the fly to present. Data in table stays untouched).

If you want to change datatype then you should alter the column. Something like:

alter table streettable alter column Street varchar(777) null

Upvotes: 3

Related Questions