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 - 2002-05-12 : 02:54:56
|
| I need a little help with a case statment. I have t-sql script that goes out to a table and updates a coulmn based on it's current information. But I can't figure out how to get it to when it does not meat any critera for updating to just leave the coulmn alone. Please help, here is my curent code.update dragonballsset earth = case earthwhen 'Regenerating 1/21 ' then 'Regenerating 2/21 'when 'Regenerating 2/21 ' then 'Regenerating 3/21 'when 'Regenerating 3/21 ' then 'Regenerating 4/21 'when 'Regenerating 4/21 ' then 'Regenerating 5/21 'when 'Regenerating 5/21 ' then 'Regenerating 6/21 'when 'Regenerating 6/21 ' then 'Regenerating 7/21 'when 'Regenerating 7/21 ' then 'Regenerating 8/21 'when 'Regenerating 8/21 ' then 'Regenerating 9/21 'when 'Regenerating 9/21 ' then 'Regenerating 10/21'when 'Regenerating 10/21' then 'Regenerating 11/21'when 'Regenerating 11/21' then 'Regenerating 12/21'when 'Regenerating 12/21' then 'Regenerating 13/21'when 'Regenerating 13/21' then 'Regenerating 14/21'when 'Regenerating 14/21' then 'Regenerating 15/21'when 'Regenerating 15/21' then 'Regenerating 16/21'when 'Regenerating 16/21' then 'Regenerating 17/21'when 'Regenerating 17/21' then 'Regenerating 18/21'when 'Regenerating 18/21' then 'Regenerating 19/21'when 'Regenerating 19/21' then 'Regenerating 20/21'when 'Regenerating 20/21' then 'Regenerating 21/21'when 'Regenerating 21/21' then 'Can be collected 'Always remember, it is all or nothing there is no in-between.Edited by - Eagle_f90 on 05/12/2002 05:03:41 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-05-12 : 03:24:46
|
| How about trying on these linesdeclare @m varchar(40)set @m='Regenerating 21/21 'select + case when substring(@m,charindex(' ',@m)+1,charindex('/',@m)-charindex(' ',@m)-1)> 1 then 'Regenerating ' + str(substring(@m,charindex(' ',@m)+1,charindex('/',@m)-charindex(' ',@m)-1)+1)+'/21' else 'Can Be Collected' endHTH-------------------------------------------------------------- |
 |
|
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2002-05-12 : 05:01:06
|
| I don't even understand what all that means, could you ecplan it then maybe I could tell you if it would work. But what I am shooting for is keeping the case statment and adding the else command to it. I have about 40 scripts that all are similar to this and need an else statment that cancels the update if the where statment does not match the coulmn.Always remember, it is all or nothing there is no in-between. |
 |
|
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2002-05-12 : 05:15:48
|
| Nevermind I figured out how to properly use the else command. Thanks anyways.Always remember, it is all or nothing there is no in-between. |
 |
|
|
|
|
|
|
|