|
Home > Archive > Microsoft SQL Server forum > November 2005 > splitting a string
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
splitting a string
|
|
| RSummersJr@gmail.com 2005-11-30, 9:23 am |
| Hello,
I have been placed in charge of migrating an old access based database
over to sql server 7.0. So far, I have imported all the tables into
sql server, but now I have come across the issue of needing to split a
string variable. For instance, in the old database, the variable for
name was such that it included both first and last names, whereas in
the new database there are seperate entities for first and last name.
I know that there is a way to write a script that will separate out the
two strings by using the "space" in between the name, but I'm
unfamiliar how to do this. Any suggestions? Thanks!
Rick
| |
| Erland Sommarskog 2005-11-30, 11:23 am |
| (RSummersJr@gmail.com) writes:
> I have been placed in charge of migrating an old access based database
> over to sql server 7.0. So far, I have imported all the tables into
> sql server, but now I have come across the issue of needing to split a
> string variable. For instance, in the old database, the variable for
> name was such that it included both first and last names, whereas in
> the new database there are seperate entities for first and last name.
> I know that there is a way to write a script that will separate out the
> two strings by using the "space" in between the name, but I'm
> unfamiliar how to do this. Any suggestions? Thanks!
I suggest that you look up "Functions" in Books Online, and have a look at
the available string functions. String maninpulation is not a strong point
in T-SQL, but there are some functions. Most commonly used for this task
are substring() and charindex().
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
|
|
|
|
|