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)
 token extraction function ?

Author  Topic 

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-01-31 : 03:55:00
Hello,

Several fields in my database are character strings made of dot-separated tokens.
Before upgrading from Access to SqlServer, I created a VB custom function to split these fields by picking one of these tokens.
I used frequently this VB function to split such fields in some queries to produce different columns.

How could I do that now on SqlServer?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-31 : 03:58:32
You can search within forums for a user defined function called SplitData which wil perform similar function.
Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-01-31 : 04:11:19
I have some hope now, thanks.
But maybe I should be a bit more precise about what I am looking for.

First, it is a scalar function that I am looking for.
It receives essentially one field value as input and just returns a substring.

In my VB function, the function was like that:

quote:
Function getToken(myString,separator,tokenPosition)

where:

myString is the 'long' string to extract from
separator is the separator used (a dot most often for my application)
tokenPosition is the position of the token within myString, would be 3 for "the third token"

I was very confortable in Access+VB, but on SQL server I a bit lost ....
Would there be a possibility to use VB functions on SqlServer?
Or how could I do the same in TSQL ?

thanks
Go to Top of Page

lalbatros
Yak Posting Veteran

69 Posts

Posted - 2008-01-31 : 04:25:11
Thanks for the impetus.
I found the solution there: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033
Go to Top of Page
   

- Advertisement -