SQLTeam.com | Weblogs | Forums

Add Text with Sequence No in a column


#1

Friends,

I have a table called "tbl_trasan" and column "tranid".

The said table contains around 1200 rows.

Now i want to update the said column with sequence number like as follows;

IVR001

IVR002

IVR003

IVR004

IVR005

....

IVR1200

Please guide me to update the column.

Thanks & Regards,


#2

Does this help

SELECT 'IVR' + RIGHT('0000' + CAST(ROW_NUMBER() OVER(ORDER BY xxxx)  AS VARCHAR(4)), 4)
FROM mytable

#3

Thanks...But i need to update the said column.....by the outcome


#4

Us an UPDATE statement instead of SELECT.

With no table definition, no code, no example data it is hard for us to help.
See http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/1 for guidance.