set nocount oncreate table #options ( optionid int identity(1,1), dboption varchar(25))create table #settings ( optionname varchar(25), currentsetting varchar(10) )insert #options (dboption)exec sp_dboptiondeclare @optionid int, @maxoptionid int, @sql varchar(100)select @optionid = 1, @maxoptionid = max(optionid)from #optionswhile @optionid <= @maxoptionidbegin select @sql = 'sp_dboption ''master'',''' + dboption + '''' from #options where optionid = @optionid insert #settings exec (@sql) set @optionid = @optionid + 1endselect * from #settingsdrop table #optionsdrop table #settings
<O>