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
 General SQL Server Forums
 New to SQL Server Programming
 Combine characters and delete duplicates

Author  Topic 

Adr
Starting Member

4 Posts

Posted - 2011-03-10 : 05:14:43
Hi!


I have a table alike the following one, with 4 columns Location, Type, Klass and Category_1.


Location / Type / Klass / Category_1
P4 / 2 / LK / A
P4 / 4 / LK / A
P4 / 7 / LK / B
P4 / 4 / LK / D
P6 / 2 / GF / A
P6 / 9 / GF / C
P6 / 4 / GF / C
P7 / 4 / LK / D


And I would like to create the following table out of it:

Location / Klass / Category_2
P4 / LK / ABD
P6 / GF / AC
P7 / LK / D


That is to say, to create category_2 names by combining the single characters of category_1 but to account for the duplicate letters only once when some rows have the same location and same category_1.


My tables are quite big so I need to do it automatically. Could anybody give me advices on how to achieve that? I'm trying to get started with SQL.


Thanks!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-10 : 05:39:45
are you using SQL 2005 / 2008 ?


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

Go to Top of Page

Adr
Starting Member

4 Posts

Posted - 2011-03-10 : 05:43:58
I am using SQL 2008.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-10 : 06:35:46
use the method describe in here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


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

Go to Top of Page

Adr
Starting Member

4 Posts

Posted - 2011-03-10 : 11:03:30
Thank you it was exactly what I needed.
Is it usual that it takes such a long time? I used the first method described on the page and it takes around 500s for a 100 rows table. Then I don't know why I can execute the query as a function but when I want to use it in a view, I get an error message that timeout expired.
Go to Top of Page
   

- Advertisement -