how to use the SELECT statement to be inserted in a column in the same table?

Asked

Viewed 28 times

0

SELECT Names,SUBSTRING(Names,10,50) AS Alias
  FROM NameToSplit;

Here I do not want to put the Aliases, but INSERT in the column Alias this Select statement.

then I need to take this column Alias and put this other script( I’m not sure if it’s right) and add in the column Aliases

SELECT Alias,
       CASE LEN(Alias) WHEN CHARINDEX('.',Alias) + 4 THEN Alias
                            ELSE STUFF(Alias, CHARINDEX('.',Alias)+5,0,'-') END

FROM (select Alias from NameToSplit)V(Aliases);

The end result needs to be something like:

Names-Alias-Aliases
idealink.core.user/core.user/core.user
idealink.core.userbadge/core.userbadge/core.user-badge
idealink.core.usergroup/core.usergroup/core.user-group
idealink.core.userloginhistory/core.userloginhistory/core.user-loginhistory

I can’t put it all together... :(

  • If I understand correctly you must make one UPDATE and not a SELECT.

  • am Newbie, not getting with the syntax,...where I would have to update?

1 answer

0


You must make a UPDATE for that reason:

UPDATE nametosplit
   SET alias = SUBSTRING(names, 10, 50);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.