I am trying to save myself from adding a lot of duplicate code to a set of SQL scripts to transfer data. I am using SQL Server.
select some_int_col, replace(a_varchar_col,'|',' ') from test_table
It is quite simple. It will return the text to a_varchar_col with all | replaced by one space.
But I got both 12 tables and 100 varchar fields. I do not want to go through and replace around each column, because its error is subject, and I am lazy;)
Is there any way to say that you need to perform a replacement on all columns of type varchar?
A more general way to ask this question:
Is there a way to get SQL Server to automatically run some arbitrary code for every column returned in the select statement? If so, can you filter which columns apply some function?
srock source share