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 2008 Forums
 Transact-SQL (2008)
 t-sql 2008 r2 concatenate

Author  Topic 

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-11-03 : 11:06:46
In an sql server 2008 r2 database, I have one column that I need to separate the values. I then need to concatenate the values together in one row from t-sql that looks like the following:

11-12 Midwest Plumbers 099.


The values in the column look like the following

099 11-12 Midwest Plumbers.

I need to split the data to look like

1. 099 is the Customer Number.

2. 11-12 is the year the customer data was valid.

3. Midwest Plumbers is the name of the company.

Notes:

1. The delimiter between the 3 fields is " " (one space).

2. The company name can contain lots of spaces.

3. There are 3 fields that need to be separated out which are:

a. Customer Number,

b. Effective Years,

c. Customer Name.

For the one row that will be displayed there needs to be 4 spaces between each value.


Thus can can you show me how to split up the in this column and then display the values in the order the customer wants to see?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-03 : 13:14:14
whats the problem with this solution? why post duplicate thread?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=189356

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -