Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Parse / Separate data in a field to different fields which are separated by Char(13)

SHIP TO: JERRY DOE 1258 Academy Sq College Park,GA  30337

I need to separate to data stored in one field to multiple fields
 
SHIP TO: JERRY DOE as ShipName
1258 Academy Sq as Ship Address
College Park as ShipCity
GA as ShipState
30337 as Zip

The name , address and zip are separated by Char(13) and the city and state by ,
0
tvae
Asked:
tvae
  • 2
1 Solution
 
radcaesarCommented:
First split the string on "," using below function

http://myitforum.com/cs2/blogs/sthompson/archive/2010/03/10/using-tsql-functions-to-split-a-delimited-string.aspx

Then Use CHARINDEX to get the data based on count.
0
 
tvaeAuthor Commented:
I am not so sure how to use the CHARINDEX. I tried that and was only successful to pull the first one but not sure how to grab the next group
0
 
radcaesarCommented:
after first one you will get 2 strings like below.

SHIP TO: JERRY DOE 1258 Academy Sq College Park
GA  30337

Again, Split the first string using CHARINDEX (Since u said that its CHAR(13)) and split the second string usng SPACE.

Refer the thread in my previous post.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now