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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to Increment on Replace statment

Author  Topic 

ShaunBetts
Starting Member

7 Posts

Posted - 2009-08-06 : 08:25:45
I want to repace some numbers at the end of some text for example shaun100000 and i want to repalce it with shaun100001 and so on to about 500000

my current SQL is

SELECT
REPALCE (_STRING_TEXT,'100000',

i am then not sure how to finish it, i a, not sure if the above is right, however i thoight it could work after takeing bits from tutorial on the web

Thanks

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-06 : 08:31:31
Hi

Am not sure what u expect...

SELECT REPLACE('shaun100000','100000','100001')




-------------------------
R..
http://code.msdn.microsoft.com/SQLExamples/
http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-06 : 08:44:38
[code]
select data,left(data,patindex('%[0-9]%',data)-1)+ltrim(substring(data, patindex('%[0-9]%',data),len(data))+1) as new_data
from
( select 'shaun100001' as data union all
select 'shaun100002' union all
select 'shaun100003'
) as t
[/code]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -