MySQL Forums
Forum List  »  Microsoft SQL Server

Re: Find unique characters in field (of all entries)
Posted by: Devart Team
Date: August 16, 2010 01:14AM

Try this code -
CREATE TABLE [dbo].[table1](
	[column1] [varchar](50) NULL
)
GO
INSERT INTO [dbo].[table1] VALUES ('abc')
INSERT INTO [dbo].[table1] VALUES ('acbd')
INSERT INTO [dbo].[table1] VALUES ('cbde')
GO

DECLARE @column1 varchar(50);
DECLARE @text varchar(max);
DECLARE @i int;
DECLARE cur CURSOR FOR SELECT column1 FROM dbo.table1;
SET @text = '';
OPEN cur;
FETCH NEXT FROM cur INTO @column1;
WHILE @@FETCH_STATUS = 0 BEGIN
	SET @i = 1;
	WHILE @i <= LEN(@column1) BEGIN
		IF CHARINDEX(SUBSTRING(@column1, @i, 1), @text) = 0
			SET @text = @text + SUBSTRING(@column1, @i, 1);
		SET @i = @i + 1;
	END;
	FETCH NEXT FROM cur INTO @column1;
END;
CLOSE cur;
DEALLOCATE cur;
SELECT @text;
GO
------------------------------------------------------
abcde
(1 row(s) affected)

Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/



Edited 1 time(s). Last edit at 08/16/2010 11:19PM by Devart Team.

Options: ReplyQuote


Subject
Written By
Posted
Re: Find unique characters in field (of all entries)
August 16, 2010 01:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.