Home All Groups Group Topic Archive Search About

SQL Server and Split function

Author
28 Mar 2005 6:33 PM
Indy
I wish to create a procedue (in SQL Server) that takes one long string -
i.e. 25 names that are separated with a '#'. In C# I use Split function to
get 25 different strings from that one, but I don't know how to do it in SQL
Server
Thx

Author
28 Mar 2005 6:54 PM
Steve Schroeder
I once used Patindex and a cursor to do something very similar similar. If
you want I can e-mail you the code as it is lengthy and wouldn't format via
a news post well anyhow.

Show quote
"Indy" <w**@www.com> wrote in message news:d29ilr$km9$1@bagan.srce.hr...
> I wish to create a procedue (in SQL Server) that takes one long string -
> i.e. 25 names that are separated with a '#'. In C# I use Split function to
> get 25 different strings from that one, but I don't know how to do it in
SQL
> Server
> Thx
>
>
Author
28 Mar 2005 7:18 PM
Chris Priede
Indy wrote:
> I wish to create a procedue (in SQL Server) that takes one long
> string - i.e. 25 names that are separated with a '#'. In C# I use
> Split function to get 25 different strings from that one, but I don't
> know how to do it in SQL Server

http://www.devx.com/tips/Tip/20009

It would be better if you didn't have to, though.  If possible, reconsider
your database design and don't store it (whatever it is) that way.  Chances
are it is a good candidate for either related rows in a separate table or
individual columns for each value.

--
Chris Priede (pri***@panix.com)
Author
29 Mar 2005 1:46 AM
Val Mazur (MVP)
Hi,

Do you need to pass some sort of array of values? If yes, then check my KB
article about how to do this with the SQL Server SP

http://support.microsoft.com/default.aspx?scid=kb;en-us;555266

--
Val Mazur
Microsoft MVP

http://xport.mvps.org



Show quote
"Indy" <w**@www.com> wrote in message news:d29ilr$km9$1@bagan.srce.hr...
>I wish to create a procedue (in SQL Server) that takes one long string -
>i.e. 25 names that are separated with a '#'. In C# I use Split function to
>get 25 different strings from that one, but I don't know how to do it in
>SQL Server
> Thx
>

AddThis Social Bookmark Button