SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 t-sql 2008 r2 concatenate
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jassie
Constraint Violating Yak Guru

308 Posts

Posted - 11/03/2013 :  11:06:46  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 11/03/2013 :  13:14:14  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000