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 ?

2
  • If possible I recommend to use some programming language to generate a big insert script for you. If not, It's possible with T-SQL Commented Jul 2, 2013 at 7:06
  • yes i want t-sql code Commented Jul 2, 2013 at 7:07

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.