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 2000 Forums
 Transact-SQL (2000)
 Substring for source data

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2007-05-04 : 09:07:49
Guys,

I have source data in the following format, I need to convert the data in the source column to respective fields - YEAR, MONTH and DAYS. I have tried using substring but it wouldnt work in all the cases.

SOURCE COLUMN YEAR MONTH DAYS
____________________________________________
11 Month(s)23 Day(s) 11 23
1 Year(s)5 Month(s) 1 5

Any suggestions/inputs would help.

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-04 : 09:41:36
Did you give us examples covering ALL of the cases? can there be a Year and only a few days, or just Days, and so on? You must provide us with representative sample data that covers all the possibilities, that is always the first step in writing any code to parse input. Otherwise, each time we write something for you, we'll need to change it as you introduce new things that you didn't tell us before. It happens all the time here and can be frustrating!

So, please closely examine your input and give us a nice, concise list of all the different possibilities to consider.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -