Need SQL script to split single field to 2 fields between a space character
Posted on 2002-03-28
I need a little help with a sql statement, I was told that SQL is not powerful enough to do this but I am leaning towards that fact that my knowledge of sql is just not powerful enough. I am looking for this:
I have a 2 fields in a table called Master_Name, the 1st is called firstname and the 2nd is called middlename.
In the firstname field I have two variations of first names, just true first names (The final product I want) or firstnames along with middle initials:
I need a sql script/statement that I can run in query analyzer that will do this;
Look at this firstname field, if is just one full name with no spaces, leave it.
Look in the firstname field If it is a group of letters (a First Name) along with space and then characters after the space, leave the first group of letters but take the characters after the space and move them to the middlename field. (I also need the space removed.)
I am looking for a simple script something like the following , that I used to pull out extra dashes, because I am not real proficient in sql:
update dba.master_name set social_sec_no = Replace(social_sec_no,'-','')
Something very simple just to move this extra data to it's own field.