Create new column using existing columns in table (SQL Server Query)

First, we need to create a column in our table like 'newCol'
then we can use these query to insert data in to newCol using existing one

update tableName set newCol= left(oldCol,1)
It will insert only first left char of existing column into newCol

update tableName set newCol = right(oldCol,(LEN(oldCol)-2))
It will leave first two char from left and insert remainning data into newCol
 
Like this we can manipulate above query with our requirement

No comments:

Post a Comment