xxxxxxxxxx
SELECT sum(COALESCE(TotalHoursM,0))
+ COALESCE(TotalHoursT,0)
+ COALESCE(TotalHoursW,0)
+ COALESCE(TotalHoursTH,0)
+ COALESCE(TotalHoursF,0) AS TOTAL FROM LeaveRequest
xxxxxxxxxx
ALTER TABLE YourTable
ADD Foo INT NULL /*Adds a new int column existing rows will be
given a NULL value for the new column*/
xxxxxxxxxx
-- add the column (as nullable)
alter table mytable add created_year int;
-- update the values on existing rows
update items set created_year = year(created_date);
-- make the column not nullable
alter table mytable alter column created_year int not null;