Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

How to ignore double or multiple spaces when finding duplicate data

$
0
0

I am trying to find duplicate data, including data with double or multiple spaces between the words that makes up the names. This is in SQL Server

Example:

Product Names in a Product Table:

Lime Cola

Lime Cola

Lime    Cola

This query will return just the first two, but not the third one:

SELECT * FROM [DBNmae].[dbo].[TableName] WHERE [productname] IN (SELECT [productname] FROM [DBName].[dbo].[TableName] GROUP BY [productname] HAVING COUNT(*) > 1)

How can I adjust the query to return all three?

That means, the double or multiple spaces within  "Lime    Cola" should be ignored.

Thanks,

Cypray


Viewing all articles
Browse latest Browse all 7129

Trending Articles