Question : How to break up a "FIrstName.LastName" record into 2 seperate variables

Source server = SQL2000
Destination server = SQL2005

I have to update some values from one system to another. The FULLNAME record in one system is like this "Jon.Doe"(all names are First.Last), in the other system it is like this "Doe, Jon"(all names are Last, First). I don't have to worry about matching the ID's or anything. For now I just need to get all the names from tblSOURCE to tblDEST with the correct formatting.

How can I query "Jon.Doe" into @FirstName, @LastName using the "." as my delimiter?

I was thinking that if I can get them into @FirstName, @LastName, I could do something like:

insert into tblDEST
set FULLNAME = @LastName + ', ' + @FirstName

I need to do this from a trigger, so there will never be more than 1 row at a time.

please help.....

Answer : How to break up a "FIrstName.LastName" record into 2 seperate variables

You can use the CharIndex function to find the "." in the string and then use the LEFT/RIGHT/SUBSTRING functions to separate the individual parts:

SET @FirstName = LEFT(FULLNAME, CharIndex('.', FULLNAME) - 1)
SET @LastName = RIGHT(FULLNAME, LEN(FULLNAME) - CHARINDEX('.', FULLNAME))
Random Solutions  
 
programming4us programming4us