Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Remove duplicate words from string

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2009-08-16 : 11:17:06
Hi all,

I have nvarchar(max) field with in it, text like

house
car
dog
green grass
pool
glass
window
car
kid
dog

all in on field, with line breaks.
But as you can see some kewords are duplicated and i want to remove them.
any idea how i can achief that?

Thanks a lot,

Mike

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-16 : 19:13:51
use fnParseList to break it down into rows, distinct it and then form the line back using concatenate records without UDF


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-08-17 : 00:12:10
Use distinct keyword, or d group by clause for removing duplicates
Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2009-08-17 : 02:54:59
Thanks for the anwsers but it i'm still a newbie in sql ;-)
i created the function but then i get this error

Msg 4121, Level 16, State 1, Line 5
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnParseList", or the name is ambiguous.

some one can give a complete working sample?

tnanks

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-17 : 02:59:12
the function fnParseList is available in the link that i posted. Click on the word fnParseList


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2009-08-17 : 05:17:38
yeah, i created the function on the server, i even see it there but i keep getting


Msg 4121, Level 16, State 1, Line 5
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnParseList", or the name is ambiguous.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-17 : 05:45:55
can you show us your query


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -