Hey Liliana-
Thanks for suggestion. I tried that, and T-SQL complains about syntax. I think that 'GO' basicly executes all the script prior to it. So because I have the Alter table, and Update statements inside of 'begin/end', the syntax gets funny in that the 'begin' has no 'end'. I need the 'begin/end' b/c if the column does not exist on the table, i don't want to issue the update statement.
The solution I have come up with is the following:
if ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'RESULTS'
AND COLUMN_NAME = 'TOTAL_VOTES'
) = 0
BEGIN
exec('ALTER TABLE [dbo].[RESULTS] ADD [TOTAL_VOTES] int not NULL DEFAULT (0);');
exec('UPDATE RESULTS SET TOTAL_VOTES = (OPTION1 + OPTION2 + OPTION3 + OPTION4 + OPTION5 + OPTION6 + OPTION7 + OPTION8 + OPTION9 + OPTION10);');
end
I am bascily forcing the T-SQL to execute by using the exec() command.
Thanks for everyone's help!
Leme know if you have a better way to solve this!
Thanks