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
 split string - months help

Author  Topic 

hardwood
Starting Member

19 Posts

Posted - 2010-06-16 : 17:57:25
I have this list of balances in a table column [PeriodChange] that is stored as a string:

-41318;-41316;-38519;-38589;-38590;-37341;-34143;-35826;-32222;-32222;-36604;-38372;0

-11471;-11471;-11471;-11471;-11471;-11471;-11314;-12046;-11973;-11973;-12110;-12154;0

-25499;-25499;-24682;-25585;-25714;-24596;-22747;-24080;-21113;-20984;-27176;-28896;0

0;0;0;350;83;83;83;83;83;183;0;0;0

etc, etc, etc...

Each number in the string is a different month though, and I want to pull out each separate month, any ideas? I've looked at some renditions of splitting strings but I don't know how they'd work with my syntax:


select
b.PeriodChange
from
Budget b
where
b.CompCode='1027' and b.FiscalYear=2010.0 and b.DivCode=1

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-06-16 : 18:07:41
Take a look at this:

http://www.sqlteam.com/article/parsing-csv-values-into-multiple-rows

Simply change the commas to semicolons and it should work.
Go to Top of Page
   

- Advertisement -