Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Database Options

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-02 : 10:19:33
Chetan Jangla writes "I am using the following to set my database options through Query Analyzer:

EXEC sp_dboption 'Wrox_Golf_Results', 'autoclose', 'True'
GO
EXEC sp_dboption 'Wrox_Golf_Results', 'read only', 'False'
GO
EXEC sp_dboption 'Wrox_Golf_Results', 'dbo use', 'False'
GO
EXEC sp_dboption 'Wrox_Golf_Results', 'single', 'False'
GO
EXEC sp_dboption 'Wrox_Golf_Results', 'autoshrink', 'False'
GO

my question is that is there a way to view how all the option names have been set along with the current setting, all in one command.

I would really appreciate your help.

Thanks
Chetan"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-02 : 10:50:43

set nocount on
create table #options (
optionid int identity(1,1),
dboption varchar(25))
create table #settings (
optionname varchar(25),
currentsetting varchar(10) )

insert #options (dboption)
exec sp_dboption

declare @optionid int, @maxoptionid int, @sql varchar(100)
select
@optionid = 1,
@maxoptionid = max(optionid)
from
#options

while @optionid <= @maxoptionid
begin
select @sql = 'sp_dboption ''master'',''' + dboption + ''''
from #options
where optionid = @optionid
insert #settings
exec (@sql)
set @optionid = @optionid + 1
end

select * from #settings
drop table #options
drop table #settings

 


<O>
Go to Top of Page
   

- Advertisement -