Ok, I'm trying to write a query in a stored procedure in SQL Server 2000. Because some of the parts of the query vary based on certain situations I construct a string that contains the query and then use the exec() function to execute the query.
My problem is that the results of the query may return a field with an apostrophe in it. I handle this in other places using the replace() function, but I can't figure out how to replace a ' in the database with a '' in the result. I've gotten rid of the ' completely, but that isn't what I need. Below is the relevant section of code.
That replaces the ' with nothing...so what is in the database as "car's" turns into "cars".
What I don't want to do is repeat the query completely for every different situation. How can I do this replace using a string and the exec() function?
Mike
My problem is that the results of the query may return a field with an apostrophe in it. I handle this in other places using the replace() function, but I can't figure out how to replace a ' in the database with a '' in the result. I've gotten rid of the ' completely, but that isn't what I need. Below is the relevant section of code.
code:<HR>Code:set @sql = @sql + 'select bk_note_id, bk_note_type_id, rtrim(footnote_reference), ' set @sql = @sql + 'RTRIM(replace(description, char(39), '''')) '
That replaces the ' with nothing...so what is in the database as "car's" turns into "cars".
What I don't want to do is repeat the query completely for every different situation. How can I do this replace using a string and the exec() function?
Mike