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
 SQL Server Development (2000)
 data after comma

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-11 : 08:13:14
Kush writes "hi there
i have a field name(fil_srt_cond) with the values of

cmpnt_name,ASC,10,2;cmpnt_stuff,DESC,2,3;...........

how can i get the data after the comma;

cmpnt_name - Tag Number
order - ASC
Char - 10
lenght - 2

so i can display them on a report with their respective column heading. thank you for your help"

SamC
White Water Yakist

3467 Posts

Posted - 2005-10-11 : 09:03:11
Lookup: SUBSTRING, PATINDEX, CHARINDEX
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2005-10-11 : 09:09:34
Please tell me you did not design this data storage.

First I would bulk import into a table to split out each row at ;.
Then you can use charIndex with substring to break it into columns.
I would then save it into a new table for actual use.


Jim
Users <> Logic
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-10-11 : 09:31:45
bcp the data out

bcp it back in to a staging table use ';' as the delimiter

bcp the data back out

bcp the data back in using "," comma as the delimter..

Done, Normalized (I guess)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-11 : 09:40:54
"how can i get the data after the comma"

What about the stuff after the semi colon - is that to be ignored, or treated as "row 2" ??

Kristen
Go to Top of Page
   

- Advertisement -