I've tried everything I can think of to find all the records in a table column (lastname) that contain an apostrophe. I know they are there (O'Brian, D'Marcus, etc.) However, I keep getting syntax errors.
Could someone PLEASE help?!!
Thanks,
KarenSELECT *
FROM theTableWithTheUnspecifiedName
WHERE lastName LIKE '%''%'-PatP|||Either way
USE Northwind
GO
SET NOCOUNT ON
CREATE TABLE myTable99(Col1 varchar(80))
CREATE INDEX IX1 ON myTable99(Col1)
GO
INSERT INTO myTable99(Col1)
SELECT 'abc' UNION ALL
SELECT 'a''c' UNION ALL
SELECT 'xyz'
GO
SELECT *
FROM myTable99
WHERE LEN(Col1) <> LEN(REPLACE(Col1,CHAR(39),''))
GO
SELECT *
FROM myTable99
WHERE Col1 LIKE '%''%'
GO
SET NOCOUNT OFF
DROP TABLE myTable99
GO
...it's a scan. I wonder if one would be more effecient than the other though|||Works fine.
Many thanks!!!!!
Karen
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment