Steve Bohler
asked on
T-sql question
Hello,
I have a database with a text column with a value of:
Designing an Organization''''s Structure
The program inserted extra apostrophes, so there are 4 apostrophes in it.
If I try and do a SELECT however to find those records with that value, using...
SELECT *
FROM tblTrackDetail
WHERE (TrackDetail_Description = 'Designing an Organization''''s Structure')
... it returns nothing.
Any suggestions?
I have a database with a text column with a value of:
Designing an Organization''''s Structure
The program inserted extra apostrophes, so there are 4 apostrophes in it.
If I try and do a SELECT however to find those records with that value, using...
SELECT *
FROM tblTrackDetail
WHERE (TrackDetail_Description = 'Designing an Organization''''s Structure')
... it returns nothing.
Any suggestions?
The program inserted extra apostrophes, so there are 4 apostrophes in it.so it seems more like a data insertion mistake to me instead.
so if the data is exactly looks like this:
Designing an Organization''''s Structure
i would suggest to do some data patching to make it such as:
Designing an Organization's Structure
and then adjust your Select SQL statement accordingly. (double the single quotes), like:
SELECT *
FROM tblTrackDetail
WHERE (TrackDetail_Description = 'Designing an Organization''s Structure')
you have to put 8 ' :)
SELECT *
FROM tblTrackDetail
WHERE (TrackDetail_Description = 'Designing an Organization''''''''s Structure')
ASKER
Unfortunately, that does not work.
Unfortunately, that does not work.
if we have 4 ' inside db, it works!
copy paste the data from db as is, so we can have a look...
create table test (col varchar(100))
SET QUOTED_IDENTIFIER OFF;
insert into test values ("Designing an Organization''''s Structure")
SET QUOTED_IDENTIFIER ON;
select * from test
-- Designing an Organization''''s Structure
ASKER
Here is another value copied and pasted from SSMS:
Building Your ''''Business Savvy''''
If I query...
select * from tbltrackdetail where (trackdetail_description = 'Building Your ''''Business Savvy''''')
no records are returned...
Building Your ''''Business Savvy''''
If I query...
select * from tbltrackdetail where (trackdetail_description = 'Building Your ''''Business Savvy''''')
no records are returned...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you update your table as
remove extra '
or
replace them with "
multiple times, until you dont get any records updated?
remove extra '
update tbltrackdetail
set trackdetail_description=replace(trackdetail_description,'''''','''')
where trackdetail_description like '%''''%'
or
replace them with "
update tbltrackdetail
set trackdetail_description=replace(trackdetail_description,'''''','"')
where trackdetail_description like '%''''%'
multiple times, until you dont get any records updated?
yea... looks weird to have extra single quotes which mean the content lose its meaning.
I guess op has a strange algorithm to update records and before updating, it replaces ' with ''
and at the end, at each update it gets duplicated...
it does not make sense :)
the update procedure should be fixed...
and at the end, at each update it gets duplicated...
it does not make sense :)
the update procedure should be fixed...
ASKER
There was both a bug in the code that did two escapes of any apostrophes
There was both a bug in the code that did two escapes of any apostrophesyea... that's why both @Huseyin and I suggested you to patch the data.
So the comparison that is done by this query is: TackDetail_Description = Designing an Organization''s Structure -> FALSE