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 |
|
amy
Starting Member
30 Posts |
Posted - 2002-05-09 : 09:55:59
|
| Hi,Below is if statement and it is working==================================declare @strSQL as nvarchar(300)If @OfficeType = 'OHA' set @strSQL = "select * from Office_T where OfficeType IN ( 'OHACO','OHARO', 'OHAFO') and PhysicalAddressState IN ( 'TX','AR','LA','NM','OK')order by OfficeCode"==========================ANd now instead of if statement I want to do the case statement========================================Select case Officetype When 'OHA' Then OfficeType = 'OHACO' Or 'OHARO' or 'OHAFO' PhysicialAddressState = 'TX' or 'AR' or 'LA' or 'NM' or 'OK'Endfrom office_torder by officecode ===============================================and here is the error I received from case statementLine 3: Incorrect syntax near '='please tell me what did I do wrong in case statementThanks alot |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-05-09 : 10:10:56
|
you don't need a case statement, you need a where clause . . .select <column_list>from office_twhere (@officetype = 'oha' and officetype in ('ohaco','oharo','ohafo') and PhysicalAddressState in ('tx','ar','la','nm','ok')) or (@officetype = 'Page47' and officetype in ('Page47a','Page47b') and PhysicalAddressState in ('md','de','va'))order by officecode <O> |
 |
|
|
amy
Starting Member
30 Posts |
Posted - 2002-05-09 : 10:31:55
|
what did you mean by 'Page47a','Page47b'?Thanksquote: you don't need a case statement, you need a where clause . . .select <column_list>from office_twhere (@officetype = 'oha' and officetype in ('ohaco','oharo','ohafo') and PhysicalAddressState in ('tx','ar','la','nm','ok')) or (@officetype = 'Page47' and officetype in ('Page47a','Page47b') and PhysicalAddressState in ('md','de','va'))order by officecode <O>
|
 |
|
|
Antonio Broughton
Starting Member
6 Posts |
Posted - 2002-05-09 : 16:25:27
|
I think thats just an example if you wanted to add more? |
 |
|
|
|
|
|
|
|