x

sql query problem

Possible Duplicate:
function or SP or cursor question

I have table as follow.

Table Name:Industrial
ID Industry
1 Metal minings & Chemicals
2 Ceramics minings & pottery
3 Pottery minings & ceramics
4 Chemicals petrol & ceramics
5 Chemicals minings & ceramics
6 Ceramics pottery & petrol

Output should be
Temp Table
ID Industry
1 Metals
2 Minings & chemicals
3 Ceramics
4 minings & pottery
5 Pottery
6 Minings & Ceramics
7 Chemicals
8 Petrol & Ceramics
9 Chemicals
10 Mining & Ceramics
11 Ceramics
12 Pottery &petrol

As you can see in Temp table there are duplicate records,it should be eliminated Actual output should be
Temp Table
ID Industry
1 Metals
2 Minings & chemicals
3 Ceramics
4 minings & pottery
5 Pottery
6 Minings & Ceramics
7 Chemicals
8 Petrol & Ceramics
9 Pottery &petrol

Delimiter used for this break down of Industry column is char(30)+char(20) I think we can declare varaible delimiter and set it to char(30)+char(10). Please help me to write complete function for this output.

more ▼

asked Jun 04, 2010 at 07:12 AM in Default

anamika gravatar image

anamika
2 1 2 2

(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1951
x14

asked: Jun 04, 2010 at 07:12 AM

Seen: 495 times

Last Updated: Jun 04, 2010 at 10:27 AM