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.
| Author |
Topic |
|
coultard1
Starting Member
4 Posts |
Posted - 2005-01-06 : 20:42:41
|
| I have a field which contains array information like this:5;10;11.77;0;0;0;0;0;0how do I just extract the first value (in the example 5) from the field? I have looked at the patindex and charindex, but my understanding is that they provide you with the index number if your extracting value is going to be constant? (i.e. always going to be 5?)I have seen examples of substr used with charindex within it, but still can't get my head around itCan anybody help? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-01-06 : 20:47:43
|
| SELECT SubString(array, 1, CharIndex(';', array)-1) FROM myTable |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-07 : 01:37:36
|
| Or you can extract any value viahttp://www.mindsdoor.net/SQLTsql/f_GetEntryDelimiitted.htmlselect dbo.f_GetEntryDelimiitted (array, @n, ';', 'N')==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|