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 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2006-04-13 : 08:30:58
|
| Hi i just want to make sure my If statement is correct.Here is what i want it to do :-(if Solve = T and ServiceEvent = f and Cancelled = F and PartsOrder = F and CRUOrder = F)or( if Solve = T and ServiceEvent = t and Cancelled = T and )then Solve_ind is true else it falseHere is the function i've written, can someone please make sure it correct, i've testing the outter if statement but i do not know a way of testing the inner if statement CREATE FUNCTION dbo.udf_Voy_Solve_ind(@Solve char(2),@ServiceEvent char(2),@cancelled char(2), @PartsOrder char(2), @CRUOrder char(2))RETURNS tinyintAS BEGIN DECLARE @Solve_ind tinyint If @Solve = 'T' and @ServiceEvent = 'F' and @Cancelled = 'F' and @PartsOrder = 'F' and @CRUOrder = 'F' Begin IF @Solve = 'T' and @ServiceEvent = 'T' and @Cancelled = 'T' Begin Set @Solve_ind = 1 End Else Set @Solve_ind = 0 Set @Solve_ind = 1 End Else Set @Solve_ind = 0RETURN @Solve_ind ENDTo test it i just used a select statement like this : select dbo.udf_Voy_Solve_ind('T','F','F','F','F') |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-13 : 08:53:18
|
| [code]CREATE FUNCTION dbo.udf_Voy_Solve_ind(@Solve char(2),@ServiceEvent char(2),@cancelled char(2), @PartsOrder char(2), @CRUOrder char(2))RETURNS tinyintAS BEGIN DECLARE @Solve_ind tinyintIf ( @Solve = 'T' and @ServiceEvent = 'F' and @Cancelled = 'F' and @PartsOrder = 'F' and @CRUOrder = 'F' ) OR ( @Solve = 'T' and @ServiceEvent = 'T' and @Cancelled = 'T') Begin Set @Solve_ind = 1 EndElse Begin Set @Solve_ind = 0 EndRETURN @Solve_ind END[/code]Srinika |
 |
|
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2006-04-13 : 09:07:48
|
| Thanks Srinika. |
 |
|
|
|
|
|
|
|