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 |
|
claireyfairy
Starting Member
1 Post |
Posted - 2010-05-13 : 11:20:05
|
| which looks up VAT rate.We have a bespoke system which is no longer supported by the sole programmer that wrote it.I have the admin system and the VAT rate is looked up on creation of an invoice or entering a Purchase Invoice.It is a stored procedure which currently reads:Create Proc spGNvatRate @Date datetime, @Code varchar(1), @Return real = 0 outputAsSet Nocount OnSet @Return = 0-- Standard RateIF @Code = 'S'BEGINIF @Date < '12/01/2008' or @Date > '12/31/2009' Set @Return = 17.5ELSE Set @Return = 15ENDI want to know how to add in another IF say if there was a new VAT rate but still only one rate at a time.BEGINIF this Set thisELSE IF this Set thisElse Set thisENDSay from 31/12/2010 the VAT rate is 20% then what would I change the code to??Many Thanks,Claire |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-13 : 11:32:05
|
the best way to do this is to remove the hardcodings from procedure logic and put the VAT rate in a table with valid_from and valid_to dates. this way you dont have edit procedure often whenever VAT changes. in process just retrieve it likeSELECT @Return =VAT_RateFROM VAT_TableWHERE @Date BETWEEN Valid_From AND Valid_To ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|