0

Im using sql server 2008.

how i insert data to sql server 2008 with combine text and number with together ?
for example add record sequency :

me1
me2
me3
me4
.
.
.

how i write query for this ?

Aleksandr Fedorenko
  • 16,594
  • 6
  • 37
  • 44
pencilvania
  • 276
  • 1
  • 4
  • 18

1 Answers1

1

Try to create Computed Column. Please refer the links for more details

  1. Specify Computed Columns in a Table

  2. Creating a computed column in SQL Server 2008

  3. Computed Column Specification in SQL Server

Computed columnn specification can have column as parameters. Like ('me'+CONVERT([nvarchar](20),[ID],(0))), where me is your text and ID is the an identity column.

For existing data, you can use an update statement.

WITH X AS 
( 
    SELECT 
        'me'+CONVERT(NVARCHAR(20), row_number() over (order by ExistingColumn)) RNum,
        * 
    FROM YourTable
) 
UPDATE X SET NewColumn=x.RNum
Community
  • 1
  • 1
TechDo
  • 18,398
  • 3
  • 51
  • 64