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 |
|
LOLCatLady
Starting Member
24 Posts |
Posted - 2011-04-05 : 16:36:48
|
| declare @sol1 char(5) declare @sol1Min varchar(50) declare @sol1Max varchar(50)declare @sol2 char(5) declare @sol2Min varchar(50) declare @sol2Max varchar(50)declare @sol3 char(5) declare @sol3Min varchar(50) declare @sol3Max varchar(50)declare @sol4 char(5) declare @sol4Min varchar(50) declare @sol4Max varchar(50)declare @sol5 char(5) declare @sol5Min varchar(50) declare @sol5Max varchar(50)declare @sol6 char(5) declare @sol6Min varchar(50) declare @sol6Max varchar(50)--Carrier codes: 500+ = A, .01 - 499.99 = Bdeclare @carrier1 char(5) set @carrier1 = 'A'declare @carrier2 char(5) set @carrier2 = 'B'--Change theseset @sol1 = '31010' set @sol1Min = 500 set @sol1Max = 999999 set @sol2 = '31011' set @sol2Min = 100 set @sol2Max = 499.99 set @sol3 = '31012' set @sol3Min = 50 set @sol3Max = 99.99set @sol4 = '31013' set @sol4Min = 25 set @sol4Max = 49.99set @sol5 = '31014' set @sol5Min = 10 set @sol5Max = 24.99set @sol6 = '31015' set @sol6Min = .01 set @sol6Max = 9.99@sol1 - @sol7 will enter the code in quotes into a column called solicitations. I'm created @carrier1 & @carrier2 to create a column for another code. I want to have an “A” in the carrier column for each record that meets the criteria of 500 – 999999 and a “B” in the carrier column when the criteria of .01 – 499.99 is met. Would I use If/Then statements: if @sol1 or @sol2 then carrier = A? Or is there a better way? |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2011-04-05 : 16:45:27
|
| Look at the "Case" operator in Books On Line.MirkoMy blog: http://mirko-marovic-eng.blogspot.com/ |
 |
|
|
LOLCatLady
Starting Member
24 Posts |
Posted - 2011-04-07 : 13:24:35
|
| Mirko - Thanks so much for your help. It took awhile for me to get the syntax down, but this is a great solution.CharleenColorado |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2011-04-08 : 03:08:29
|
You are welcome. I am glad you figured it out by yourself. MirkoMy blog: http://mirko-marovic-eng.blogspot.com/ |
 |
|
|
|
|
|