Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-01-13 : 14:47:07
|
[code]I need a query to autoincrement the value with number.Ex:Table1:Value varchar(10)value-----KOO0QOO0TOO0Expected output:value-----KOO01QOO02TOO03[/code]Thanks for your help in advance.. |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-13 : 15:04:14
|
What's the increment ordered by? The value? Does it ever reset?--Gail ShawSQL Server MVP |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-01-13 : 15:13:35
|
Thanks GilaMonster..Increment order is by values and it does not reset.. |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-13 : 15:27:48
|
SELECT [value] + CAST(Row_Number() OVER (order by [value]) AS Varchar(4)) FROM ....Not tested since you didn't provide table definitions, but should give the general idea.--Gail ShawSQL Server MVP |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-01-13 : 15:36:31
|
Thanks it works.. |
 |
|
|
|
|