USE trial1

-- Update fPasswordEnable and fLogOnTextBox for FogBugz earlier then v8.16
-- If you are using FogBugz v8.16 or later, these values will have no effect on your FogBugz. This is why we are not going to insert them, just update them if they exist.
UPDATE Setting SET sValue = 1 WHERE sKey = 'fPasswordEnable'
UPDATE Setting SET sValue = 1 WHERE sKey = 'fLogOnTextBox'

-- Insert iAuthType if it doesn't exists
-- If your are using FogBugz version earlier then v8.16 this configuration value will have no effect on your FogBugz.
INSERT INTO Setting
(sKey, sValue)
SELECT insertData.sKey, insertData.sValue 
FROM Setting sourceData
RIGHT JOIN (Select 'iAuthType' as sKey, 0 as sValue) insertData
  ON sourceData.sKey = insertData.sKey 
WHERE sourceData.sKey IS NULL 

-- Update iAuthType to default value 0 to enable login boxes.
UPDATE Setting SET sValue = 0 WHERE sKey = 'iAuthType'

-- Select the updated records to check the updated values.
SELECT * FROM dbo.Setting WHERE sKey IN ('iAuthType', 'fPasswordEnable', 'fLogOnTextBox')