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 |
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2003-01-10 : 02:57:28
|
I have a column named "movetime" and it always contains an entree in the form of "xx/xx" (where xx is a number) What I want to do is write an ASP (using vbscript) script that takes the entree in the column and add "1" to the first set of numbers. So if the entree was 1/30 it would update it to 2/30. I know I could just do an if 1/30 then 2/30 but there is a small issue with that. There are hundreds of combos for the xx/xx entree. So I am looking for an easy way to do it. Anyone have any ideas?--For those with wings, fly to your dreamsIt is all or nothing there is no in-betweenRemember who I was... For me |
|
rihardh
Constraint Violating Yak Guru
307 Posts |
Posted - 2003-01-10 : 03:43:28
|
Why a VBS when you can do it with T-SQL. |
 |
|
Peter Dutch
Posting Yak Master
127 Posts |
Posted - 2003-01-10 : 04:02:46
|
Hey Eagle,Are you going to make a habit of it to post the same questions on different forums? Technically maybe not crossposting, but I just answered it on the other forum..... |
 |
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-01-10 : 04:18:21
|
So this is just one varchar column containing the two bits of information separated by a / then? And the number can be any size?You could do it in SQL like this ...create table #moo (thing varchar (20) null)insert into #moo values ('1/10')insert into #moo values ('2/10')insert into #moo values ('3/30')insert into #moo values ('4/10')insert into #moo values ('5/50')insert into #moo values ('11/50')insert into #moo values ('12/50')insert into #moo values ('128/90')insert into #moo values ('129/9')Select * from #mooselect thing as old, left (thing,(charindex('/',thing)-1)) as orig, cast (left (thing,(charindex('/',thing)-1)) as int) + 1 as plus1, cast (cast (left (thing,(charindex('/',thing)-1)) as int) + 1 as varchar) + '/' + right (thing, len(thing) - charindex('/',thing)) as newfrom #mooupdate #moo set thing = cast (cast (left (thing,(charindex('/',thing)-1)) as int) + 1 as varchar) + '/' + right (thing, len(thing) - charindex('/',thing))select * from #moodrop table #moo-------Moo. |
 |
|
|
|
|
|
|