Hi!
Venkat is right, there is no specific function to do this. But, we can try a way to accomplish this.
[1] Let us assume that you have a table emps that is created something like this -
Create table emps ( id identity(1,1) , name varchar(20))
You can alter the table and add the identity column.
[2] Insert the same entry in all the rows of the table using -
Insert into emps values ('Stuart Stalker')
id will automatically updated like counter, you need not enter it. Repeat the above statement as many time you like.
[3] Now, if you want to select only from the table. Use Select. I am using Update statement in my example.
UPDATE emps set name=substring(name,1,6)+cast(id as char(1))+substring(name,8,20)+cast(id+1 as char(1))
This statement will Update your table permanently. So, instead of that you can do this -
SELECT name=substring(name,1,6)+cast(id as char(1))+substring(name,8,20)+cast(id+1 as char(1))
from emps
This will produce output like this -
name
----------------------------
Stuart1Stalker2
Stuart2Stalker3
Stuart3Stalker4
Stuart4Stalker5
Stuart5Stalker6
The result is based upon my assumption. Your case may be different. I can not recommend this. But, you can try this if this is so urgent to do. Tell us clear scenario of table, if you are do not get any solution.
Reply when you read this.
|