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.
Author |
Topic |
tomus2008
Starting Member
1 Post |
Posted - 2010-09-25 : 04:37:56
|
hi i write the code for splitting name into first middle and last name and update it into the same table , but it shows errorthe table idname contain five coloumn id name fname mname and lname i pass onlu id and name from front end to tablecreate trigger tr1 on idnamefor insertasbeginDECLARE @I1 int, @I2 int, @I3 intUPDATE USET @I1 = CHARINDEX(' ', [name] + ' ') , [fname] = LEFT( [name], @I1-1) , @I2 = NullIf(CHARINDEX(' ', [name] + ' ', @I1+1), 0) , [mname] = SUBSTRING( [name], @I1+1, @I2-@I1-1) , @I3 = NullIf(CHARINDEX(' ', [name] + ' ', @I2+1), 0) , [lname] = SUBSTRING( [name], @I2+1, @I3-@I2-1)FROM dbo.idname AS Uend |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-25 : 12:37:47
|
how will you determine tha parts of name? will format of name be consistent?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-25 : 13:58:56
|
Also you should join inserted on id instead of updating the whole table for each insert. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|