Showing posts with label cast. Show all posts
Showing posts with label cast. Show all posts

Monday, 23 January 2017

Round Up To Next Whole Number TSQL



Image result for round up numbers


I was looking for a way to round up the results of a query to the next whole number and after
 fair bit of searching the net and experimenting to get this to work in SQL 2005
The result was


declare @totalpallets as int
declare @total as int
declare @palletsize as int


set total_pallets =  (select ceiling(cast(@total as float)/cast(@palletsize as float)))



This does the job admirably

Multi Point USB Charger

  USB Plug Charger, 4-Port USB Fast Charger Plug with 33W Intelligent Quick Charge 3.0 Wall Charger, Multi USBPower Adapter UK Fast Charging...