Search code examples
sql-serverselectinsert-into

SQL Server : select and add to new column of same table


Given that kind of syntax

SELECT 'all the left part of 'email' column before @'
FROM [dbname].[tablename]

How to insert the SELECT query into a new column called 'email_left'?

PS. for simplicity I do not show the long query after my select query.


Solution

  • it is an update:

    UPDATE x
    SET    [new column created outside this statement] = 'all the left part of "email" column before @'
    FROM [dbname].[tablename] AS x