Reputation: 27
I need help with combining multiple replace/cast functions into the same query.
I already have a preexisting select statement for a particular column(col_name):
CAST(REPLACE(SUBSTRING(col_name, 1, 4000), '''', '''''') AS VARCHAR(4000)) AS col_name
I want to include a command to replace tabs within the column (loading from SQL Server to IBM db2 using Visual Studio and I have tabs within the columns of a tab-delimited table...super fun):
REPLACE(col_name, CHAR(9), '')
How would I combine these?
Upvotes: 0
Views: 1220
Reputation: 658
Take your first statement:
CAST(replace(substring(col_name,1,4000),'''','''''') AS VARCHAR(4000)) as col_name
Replace the col_name in your second statement with the above cast statement:
REPLACE(CAST(replace(substring(col_name,1,4000),'''','''''') AS VARCHAR(4000)), CHAR(9), '') as col_name
Upvotes: 2