home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Business Development Kit / PRODUCT_CD.iso / sqlsvr / i386 / configur.sql < prev    next >
Encoding:
Text File  |  1995-12-14  |  23.4 KB  |  784 lines

  1.  
  2. -- -
  3. /********1*********2*********3*********4*********5*********6*********7**
  4. Configur.SQL             1995/12/13 13:39   6.50.164
  5.  
  6.    This file upgrades sysconfigures from 4.2 or 6.0 to 6.5, only
  7. as part of a 6.5 setup.
  8.    This file also ensures some minimum-maximum values for certain
  9. configurations.
  10.    Do not run this file against a MS SQL version earlier than 4.2.
  11.    Origin of this file was 6.00.121 InstProc.SQL.
  12.  
  13. Copyright Microsoft, Inc. 1994, 1995, 1996
  14. All Rights Reserved.
  15. Use, duplication, or disclosure by the United States Government
  16. is subject to restrictions as set forth in subdivision (c) (1) (ii)
  17. of the Rights in Technical Data and Computer Software clause
  18. at CFR 252.227-7013. Microsoft, Inc. One Microsoft Way, Redmond WA
  19. 98052.
  20. *********1*********2*********3*********4*********5*********6*********7*/
  21.  
  22. Go
  23. use master
  24. set nocount on
  25. Go
  26. dump transaction master with no_log
  27. Go
  28.  
  29. declare @vdt varchar(99)
  30. select  @vdt = convert(varchar,getdate(),113)
  31. raiserror('
  32. Starting Install\Configur.SQL at %s',1,1 ,@vdt)
  33. raiserror('
  34. This file upgrades sysconfigures from MS SQL Server 4.2x to 6.0.',1,1)
  35. Go
  36.  
  37.  
  38. --------------  Only for 6.5 sqlservr.exe  --------------------
  39.  
  40. if (@@version like '%6.50.%')
  41.    begin
  42.    raiserror('
  43. The @@version is like  6.50.  , for which this file is designed.   Will proceed.',1,1)
  44.    end
  45. else
  46.    begin
  47.    raiserror('
  48. The @@version is NOT like  6.50.  , for which this file is designed.
  49. Will NOT proceed.',22,127) with log
  50.    end
  51. Go
  52.  
  53.  
  54.  
  55. declare @int1 integer
  56.  
  57. raiserror('
  58. Making sure that updates to system tables are allowed.',1,1)
  59.  
  60. if (     exists (select * from sysobjects where name='sp_configure')
  61.    AND   1 <> (select value from syscurconfigs where config = 102)
  62.    )
  63.         begin                                          -- Query tree compatible
  64.         exec @int1 = sp_configure 'allow updates',1    -- config=102
  65.         if @@error <> 0 or @int1 <> 0
  66.                 raiserror('Bad sp_configure exec at top of Configur.SQL, killing spid.'
  67.                         ,22,127) with log
  68.         reconfigure with override
  69.         raiserror('sp_configure & reconfigure just now turned on ''allow updates''.',1,1)
  70.         end
  71. Go
  72.  
  73. /***
  74.    Make sure server was started in single user mode or that sp_configure
  75. was used to enable updates to system tables.
  76. ***/
  77.  
  78. if (select value from syscurconfigs where config = 102) <> 1
  79.         raiserror('
  80. Cannot run Configur.SQL unless updates to system tables are enabled.
  81. Shutdown server and restart with the ''-m'' option (or use sp_configure?) to enable updates to system tables.'
  82.                         ,22,127) with log
  83. Go
  84.  
  85. dump transaction master with no_log
  86. Go
  87.  
  88.  
  89. ---- 118 ('remote logins') is obsolete in 6.5.
  90. delete from sysconfigures where config in (118)
  91. Go
  92.  
  93.  
  94. /***********
  95.       We need to know whether we are in the process of upgrading
  96. a 4.2x or a 6.0+ MS SQL Server.   Most of the remaining logic
  97. in this file will be bypassed unless we are upgrading a 4.2x.
  98.       Our technique will be to query for the presence of
  99. certain config rows which we know exist in 4.2x but not in 6.0+,
  100. plus for some rows we know are new in 6.0, plus for some rows
  101. we know are new in 6.5.
  102.  
  103.  
  104. IN 4.2 BUT NOT IN 6.0:
  105. ------------------------
  106. 116   devices
  107. 133   infect ticks
  108.  
  109.  
  110.  
  111. IN 6.0 BUT NOT IN 6.5:
  112. ------------------------
  113. .
  114.  
  115.  
  116.  
  117. NEW IN 6.0 (sample):
  118. ------------------------
  119. 1510  RA pre-fetches
  120. 1522  LE threshold minimum
  121.  
  122.  
  123.  
  124. NEW IN 6.5:
  125. ------------------------
  126.  542  remote proc trans                -- (DTC Viper)
  127.  543  remote conn timeout
  128. 1110  time slice                       -- (Issue 4.2x & 6.0)
  129. 1119  remote sites
  130. 1534  user options                     -- (@@options)
  131. 1535  affinity mask
  132.  
  133. ***********/
  134.  
  135.  
  136. if exists (select * from sysconfigures where config in (542,1535))
  137.    begin
  138.    raiserror('
  139. sysconfigures rows are already at the 6.5+ version, so most of
  140. the remaining 6.0 logic in this file will be bypassed.',1,1)
  141.  
  142.    GOTO LABEL_60BYPASS
  143.  
  144.    end
  145. else
  146.    raiserror('
  147. sysconfigures rows are not yet at the 6.5+ version.   Will proceed.',1,1)
  148.  
  149.  
  150.  
  151. if exists (select * from sysconfigures where config in (1510,1522))
  152.    begin
  153.    raiserror('
  154. sysconfigures rows are already at the 6.0+ version, so most of
  155. the remaining 6.0 logic in this file will be bypassed.',1,1)
  156.  
  157.    GOTO LABEL_60BYPASS
  158.  
  159.    end
  160. else
  161.    raiserror('
  162. sysconfigures rows are not yet at the 6.0+ version.   Will proceed.',1,1)
  163.  
  164.  
  165. raiserror('
  166. Making changes to sysconfigures rows up to 6.0 .....',1,1)
  167.  
  168.  
  169. -------- Caution re 123/1123
  170.  
  171. raiserror('Delete 4.2x rows that are obsolete in 6.0.',1,1)
  172.  
  173. delete
  174.       from
  175.              sysconfigures
  176.       where
  177.             (config in ( 110,114,116,132,133 )
  178.  
  179.             or    config between  118 and  122
  180.             )
  181.  
  182. raiserror('Number of rows deleted as obsolete in 6.0 was %d'
  183. ,1,1,@@rowcount)
  184.  
  185.  
  186.  
  187.  
  188. raiserror('Delete rows that are to be added in 6.0.',1,1)
  189.  
  190. delete
  191.       from
  192.              sysconfigures
  193.       where
  194.             (config in ( 505,508,518,521,523,540,541
  195.                         ,1522)
  196.  
  197.             or    config between  502 and  503
  198.             or    config between 1504 and 1506
  199.             or    config between 1509 and 1520
  200.             or    config between 1530 and 1533
  201.             )
  202.  
  203. raiserror('Number of rows deleted as to-be-added in 6.0 was %d'
  204. ,1,1,@@rowcount)
  205.  
  206.  
  207.  
  208.  
  209. if exists (select * from sysconfigures where config = 123)
  210.    begin
  211.    update sysconfigures set config = 1123 where config = 123
  212.    raiserror('config value=123 (sortorder) was Updated to 1123.',1,1)
  213.    end
  214. else
  215.    raiserror('There is already NO row where value=123 (sortorder), so 1123 must already exist.',1,1)
  216.  
  217.  
  218.  
  219. raiserror('Updating a few statuses to Dynamic.',1,1)
  220.  
  221. update sysconfigures set status = status | 1
  222. where config in (101,102,115)
  223. and   status & 1 = 0
  224.  
  225. raiserror('Number of rows updated for status dynamic bit was %d'
  226. ,1,1,@@rowcount)
  227.  
  228.  
  229.  
  230. /***
  231.    If sysconfigures for TempDB in RAM was 1 (Mb), this was a 4.2 database.
  232. We will keep TempDB in RAM, but it will just be 2 Mb and will
  233. need to manually be altered later!   If it is a value higher than 1,
  234. we will not touch it.
  235.    First, we add a config=501 row if none is present.
  236. ***/
  237.  
  238. -------- Add a 501 row if none is present; but not "in RAM".
  239.  
  240. if not exists (select * from sysconfigures where config = 501)
  241.    begin
  242.    insert into   sysconfigures
  243.           values (501,0,'TempDB in RAM option',0)
  244.    raiserror('Just finished Insert of 501 ''TempDB in RAM''.',1,1)
  245.    end
  246. else
  247.    raiserror('501 ''TempDB in RAM'' row already present; fine.',1,1)
  248.  
  249.  
  250. update   sysconfigures
  251.    set   value=2 ,comment='TempDB in RAM option' ,status=0 
  252.    where config=501 and value=1
  253.  
  254. if @@rowcount=1
  255.    raiserror('The pre-existing 501 ''TempDB in RAM'' row was found to
  256. be in need of an Update, and was Updated.',1,1)
  257. else
  258.    raiserror('The pre-existing 501 ''TempDB in RAM'' row does not need Updating.',1,1)
  259.  
  260.  
  261.  
  262. /***
  263. Insert new configuration options.   These comments are sometimes not
  264. exactly equal to their corresponding spt_values.name strings.
  265.    Status Bits:   1=dynamic ,2=advanced
  266. ***/
  267.  
  268. raiserror('
  269. Begin approx 28 Inserts up to 6.0.
  270. Will report only failed or bypassed Inserts....
  271. ',1,1)
  272.  
  273.  
  274.  
  275.  
  276. if not exists (select * from sysconfigures
  277.                          where value=502)
  278.    insert into sysconfigures values (502,8,'Maximum outstanding async IOs',0)
  279. else raiserror('Insert failed for    502 config!',22,127) with log
  280.  
  281.  
  282. if not exists (select * from sysconfigures
  283.                          where value=503)
  284.    insert into sysconfigures values (503,255,'Maximum worker threads',1)
  285. else raiserror('Insert failed for    503 config!',22,127) with log
  286.  
  287.  
  288. if not exists (select * from sysconfigures
  289.                          where value=505)
  290.    insert into sysconfigures values (505,4096, 'Default network packet size',1)
  291. else raiserror('Insert failed for    505 config!',22,127) with log
  292.  
  293.  
  294. if not exists (select * from sysconfigures
  295.                          where value=508)
  296.    insert into sysconfigures values (508,3,'RA worker threads',0)
  297. else raiserror('Insert failed for    508 config!',22,127) with log
  298.  
  299.  
  300. if not exists (select * from sysconfigures
  301.                          where value=518)
  302.    insert into sysconfigures values (518,0,'show advanced options',1)
  303. else raiserror('Insert failed for    518 config!',22,127) with log
  304.  
  305.  
  306. if not exists (select * from sysconfigures
  307.                          where value=521)
  308.    insert into sysconfigures values (521,0,'LE threshold percent',1)
  309. else raiserror('Insert failed for    521 config!',22,127) with log
  310.  
  311.  
  312. if not exists (select * from sysconfigures
  313.                          where value=523)
  314.    insert into sysconfigures values (523,200,'LE threshold maximum',1)
  315. else raiserror('Insert failed for    523 config!',22,127) with log
  316.  
  317.  
  318. if not exists (select * from sysconfigures
  319.                          where value=540)
  320.    insert into sysconfigures values (540,5,'backup threads',0)
  321. else raiserror('Insert failed for    540 config!',22,127) with log
  322.  
  323.  
  324. if not exists (select * from sysconfigures
  325.                          where value=541)
  326.    insert into sysconfigures values (541,1,'backup buffer size',1)
  327. else raiserror('Insert failed for    541 config!',22,127) with log
  328.  
  329.  
  330. if not exists (select * from sysconfigures
  331.                          where value=1504)
  332.    insert into sysconfigures values (1504,7993,'Hash buckets',2)
  333. else raiserror('Insert failed for    1504 config!',22,127) with log
  334.  
  335.  
  336. if not exists (select * from sysconfigures
  337.                          where value=1505)
  338.    insert into sysconfigures values (1505,64,'Number of sort pages',3)
  339. else raiserror('Insert failed for    1505 config!',22,127) with log
  340.  
  341.  
  342. if not exists (select * from sysconfigures
  343.                          where value=1506)
  344.    insert into sysconfigures values (1506,8,'Maximum lazywrite IO',3)
  345. else raiserror('Insert failed for    1506 config!',22,127) with log
  346.  
  347.  
  348. if not exists (select * from sysconfigures
  349.                          where value=1509)
  350.    insert into sysconfigures values (1509,5,'RA slots per thread',2)
  351. else raiserror('Insert failed for    1509 config!',22,127) with log
  352.  
  353.  
  354. if not exists (select * from sysconfigures
  355.                          where value=1510)
  356.    insert into sysconfigures values (1510,3,'RA pre-fetches',3)
  357. else raiserror('Insert failed for    1510 config!',22,127) with log
  358.  
  359.  
  360. if not exists (select * from sysconfigures
  361.                          where value=1511)
  362.    insert into sysconfigures values (1511,15,'RA delay',3)
  363. else raiserror('Insert failed for    1511 config!',22,127) with log
  364.  
  365.  
  366. if not exists (select * from sysconfigures
  367.                          where value=1512)
  368.    insert into sysconfigures values (1512,3,'RA cache miss limit',3)
  369. else raiserror('Insert failed for    1512 config!',22,127) with log
  370.  
  371.  
  372. if not exists (select * from sysconfigures
  373.                          where value=1513)
  374.    insert into sysconfigures values (1513,4,'RA cache hit limit',3)
  375. else raiserror('Insert failed for    1513 config!',22,127) with log
  376.  
  377.  
  378. if not exists (select * from sysconfigures
  379.                          where value=1514)
  380.    insert into sysconfigures values (1514,10000,'spin counter',3)
  381. else raiserror('Insert failed for    1514 config!',22,127) with log
  382.  
  383.  
  384. if not exists (select * from sysconfigures
  385.                          where value=1515)
  386.    insert into sysconfigures values (1515,20,'Free buffers',3)
  387. else raiserror('Insert failed for    1515 config!',22,127) with log
  388.  
  389.  
  390. if not exists (select * from sysconfigures
  391.                          where value=1516)
  392.    insert into sysconfigures values (1516,0,'SMP concurrency',2)
  393. else raiserror('Insert failed for    1516 config!',22,127) with log
  394.  
  395.  
  396. if not exists (select * from sysconfigures
  397.                          where value=1517)
  398.    insert into sysconfigures values (1517,0,'Priority boost',2)
  399. else raiserror('Insert failed for    1517 config!',22,127) with log
  400.  
  401.  
  402. if not exists (select * from sysconfigures
  403.                          where value=1519)
  404.    insert into sysconfigures values (1519,5,'remote login timeout',3)
  405. else raiserror('Insert failed for    1519 config!',22,127) with log
  406.  
  407.  
  408. if not exists (select * from sysconfigures
  409.                          where value=1520)
  410.    insert into sysconfigures values (1520,0,'remote query timeout',3)
  411. else raiserror('Insert failed for    1520 config!',22,127) with log
  412.  
  413.  
  414. if not exists (select * from sysconfigures
  415.                          where value=1522)
  416.    insert into sysconfigures values (1522,20,'LE threshold minimum',3)
  417. else raiserror('Insert failed for    1522 config!',22,127) with log
  418.  
  419.  
  420. if not exists (select * from sysconfigures
  421.                          where value=1530)
  422.    insert into sysconfigures values (1530,0,'logwrite sleep (ms)',1)
  423. else raiserror('Insert failed for    1530 config!',22,127) with log
  424.  
  425.  
  426. if not exists (select * from sysconfigures
  427.                          where value=1531)
  428.    insert into sysconfigures values (1531,-1,'cursor threshold',3)
  429. else raiserror('Insert failed for    1531 config!',22,127) with log
  430.  
  431.  
  432. if not exists (select * from sysconfigures
  433.                          where value=1532)
  434.    insert into sysconfigures values (1532,0,'set working set size',2)
  435. else raiserror('Insert failed for    1532 config!',22,127) with log
  436.  
  437.  
  438. if not exists (select * from sysconfigures
  439.                          where value=1533)
  440.    insert into sysconfigures values (1533,10,'resource timeout',3)
  441. else raiserror('Insert failed for    1533 config!',22,127) with log
  442.  
  443.  
  444.  
  445. LABEL_60BYPASS:
  446.  
  447.  
  448. raiserror('Logic is now passed the Inserts for 6.0.',1,1)
  449.  
  450. Go
  451.  
  452.  
  453. ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
  454.  
  455.  
  456. if exists (select * from sysconfigures where config in (542,1534,1535))
  457.    begin
  458.    raiserror('
  459. sysconfigures rows are already at the 6.5+ version, so most of
  460. the remaining 6.5 logic in this file will be bypassed.',1,1)
  461.  
  462.    GOTO LABEL_65BYPASS
  463.  
  464.    end
  465. else
  466.    raiserror('
  467. sysconfigures rows are not yet at the 6.5+ version.   Will proceed.',1,1)
  468.  
  469.  
  470.  
  471. raiserror('
  472. Making changes to sysconfigures rows up to 6.5 ....',1,1)
  473.  
  474.  
  475.  
  476. raiserror('Delete 6.0 rows that are obsolete in 6.5.',1,1)
  477.  
  478. delete
  479.       from
  480.              sysconfigures
  481.       where
  482.             (config in (  118)
  483.             )
  484.  
  485. raiserror('Number of rows deleted as obsolete in 6.5 was %d'
  486. ,1,1,@@rowcount)
  487.  
  488.  
  489.  
  490. raiserror('Delete rows that are new to-be-added in 6.5.',1,1)
  491.  
  492. delete
  493.       from
  494.              sysconfigures
  495.       where
  496.             (config in (542,543,1110,1119,1534,1535)
  497.             )
  498.  
  499. raiserror('Number of rows deleted as new to-be-added in 6.5 was %d'
  500. ,1,1,@@rowcount)
  501.  
  502.  
  503.  
  504.  
  505. raiserror('
  506. Begin approx 6 Inserts up to 6.5.
  507. Will report only failed or bypassed Inserts....
  508. ',1,1)
  509.  
  510.  
  511. ----(config ,value ,comment ,status)
  512.  
  513.  
  514. if not exists (select * from sysconfigures
  515.                          where value=542)
  516.    insert into sysconfigures values (542, 0, 'Create DTC transaction for remote procedures', 0)
  517. else raiserror('Insert failed for    542 config!',22,127) with log
  518.  
  519.  
  520. if not exists (select * from sysconfigures
  521.                          where value=543)
  522.    insert into sysconfigures values (543, 10, 'Remote Connection Timeout period (minutes)', 0)
  523. else raiserror('Insert failed for    543 config!',22,127) with log
  524.  
  525.  
  526.  
  527. if not exists (select * from sysconfigures
  528.                          where value=1110)
  529.    insert into sysconfigures values (1110,100,'Average time slice per process in milliseconds',3)
  530. else raiserror('Insert failed for    1110 config!',22,127) with log
  531.  
  532.  
  533. if not exists (select * from sysconfigures
  534.                          where value=1119)
  535.    insert into sysconfigures values (1119,10,'Number of remote sites',2)
  536. else raiserror('Insert failed for    1119 config!',22,127) with log
  537.  
  538.  
  539. if not exists (select * from sysconfigures
  540.                          where value=1534)
  541.    insert into sysconfigures values (1534,0,'user options',1)
  542. else raiserror('Insert failed for    1534 config!',22,127) with log
  543.  
  544.  
  545. if not exists (select * from sysconfigures
  546.                          where value=1535)
  547.    insert into sysconfigures values (1535,0,'affinity mask',2)
  548. else raiserror('Insert failed for    1535 config!',22,127) with log
  549.  
  550.  
  551.  
  552.  
  553. LABEL_65BYPASS:
  554.  
  555.  
  556. raiserror('Now passed all of the 6.5 Inserts.',1,1)
  557.  
  558. Go
  559.  
  560.  
  561. ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
  562.  
  563. ---- (Old .C gen Config.SQL)
  564.  
  565.  
  566. use master
  567. Go
  568.  
  569. raiserror('
  570. Handle NewInstall/Upgrade configuration value issues....
  571. ',1,1)
  572.  
  573. raiserror('Any changes made to pre-existing configuration values will be reported ....
  574. ',1,1) with nowait
  575. Go
  576.  
  577. declare @OldValue   integer
  578.        ,@NewValue   integer
  579.        ,@OKMin      integer
  580.        ,@OKMax      integer
  581.        ,@ConfigName varchar(35)
  582.        ,@ConfigNum  integer
  583.  
  584. declare @Registry_SetupStatus varchar(255) ,@RegistryOrig_SetupStatus varchar(255)
  585.  
  586. ---- Upgrade1.SQL ensures xp_regread is ready.
  587. execute master..xp_regread 'HKEY_LOCAL_MACHINE'
  588.       ,'SOFTWARE\Microsoft\MSSQLServer\Setup' ,'SetupStatus'
  589.       ,@RegistryOrig_SetupStatus OUTPUT
  590.  
  591.  
  592. select @Registry_SetupStatus = Isnull(@RegistryOrig_SetupStatus,'NewInstall')
  593.  
  594. raiserror('
  595. (Registry SetupStatus=''%s'', will be treated as ''%s''.)'
  596. ,1,1,@RegistryOrig_SetupStatus,@Registry_SetupStatus)
  597.  
  598. IF @Registry_SetupStatus = 'Installed'
  599.    begin
  600.    raiserror('The value ''%s'' is an invalid RegistryStatus value at this phase, ABORTING SetUp!'
  601.             ,22,127,@Registry_SetupStatus)
  602.    end
  603.  
  604. IF @Registry_SetupStatus NOT IN ('Tweaked','Upgrade','NewInstall')
  605.    begin
  606.    raiserror('The value ''%s'' is an unrecognized RegistryStatus, ABORTING SetUp!'
  607.             ,22,127,@Registry_SetupStatus)
  608.    end
  609.  
  610.  
  611.  
  612. IF @Registry_SetupStatus IN ('Upgrade') -- Then no need to install these initial values.
  613.    GOTO LABEL_25AFTERINSTALL
  614.  
  615. raiserror('Now installing initial configuration values...',1,1)
  616.  
  617.  
  618. -------------------------------------------------------
  619. SELECT @NewValue=5 ,@ConfigName='recovery interval' ,@ConfigNum=101 -----------
  620.  
  621. update sysconfigures set value=@NewValue where config=@ConfigNum
  622.  
  623. -------------------------------------------------------
  624. SELECT @NewValue=30 ,@ConfigName='procedure cache' ,@ConfigNum=108
  625.  
  626. update sysconfigures set value=@NewValue where config=@ConfigNum
  627.  
  628. -------------------------------------------------------
  629. SELECT @NewValue=0 ,@ConfigName='fill factor' ,@ConfigNum=109
  630.  
  631. update sysconfigures set value=@NewValue where config=@ConfigNum
  632.  
  633. -------------------------------------------------------
  634. SELECT @NewValue=2 ,@ConfigName='database size' ,@ConfigNum=111
  635.  
  636. update sysconfigures set value=@NewValue where config=@ConfigNum
  637.  
  638. -------------------------------------------------------
  639. SELECT @NewValue=0 ,@ConfigName='media retention' ,@ConfigNum=112
  640.  
  641. update sysconfigures set value=@NewValue where config=@ConfigNum
  642.  
  643. -------------------------------------------------------
  644. SELECT @NewValue=0 ,@ConfigName='recovery flags' ,@ConfigNum=113
  645.  
  646. update sysconfigures set value=@NewValue where config=@ConfigNum
  647.  
  648. -------------------------------------------------------
  649. SELECT @NewValue=20 ,@ConfigName='open databases' ,@ConfigNum=105
  650.  
  651. update sysconfigures set value=@NewValue where config=@ConfigNum
  652.  
  653. -------------------------------------------------------
  654. SELECT @NewValue=5000 ,@ConfigName='locks' ,@ConfigNum=106
  655.  
  656. update sysconfigures set value=@NewValue where config=@ConfigNum
  657.  
  658. -------------------------------------------------------
  659. SELECT @NewValue=500 ,@ConfigName='open objects' ,@ConfigNum=107
  660.  
  661. update sysconfigures set value=@NewValue where config=@ConfigNum
  662.  
  663. -------------------------------------------------------
  664. SELECT @NewValue=20 ,@ConfigName='user connections' ,@ConfigNum=103
  665.  
  666. update sysconfigures set value=@NewValue where config=@ConfigNum
  667.  
  668.  
  669.  
  670. -----------------------------
  671. LABEL_25AFTERINSTALL:
  672. -----------------------------
  673.  
  674.  
  675. raiserror('At  LABEL_25AFTERUPGRADE  ....',1,1)
  676.  
  677.  
  678.  
  679. IF @Registry_SetupStatus IN ('Tweaked','NewInstall') -- Then no need to adjust user's unsafe values.
  680.    GOTO LABEL_36AFTERUPGRADE
  681.  
  682. raiserror('Now ensuring minimum values for certain configurations....',1,1)
  683.  
  684.  
  685. -------------------------------------------------------
  686. SELECT @NewValue=20 ,@ConfigName='open databases' ,@ConfigNum=105 -------------
  687.  
  688. select @OldValue = min(cf.value) from sysconfigures cf ,spt_values val
  689.    where val.name=@ConfigName and val.type='C  ' and cf.config=val.number
  690.    and   cf.value < @NewValue
  691.  
  692. if @OldValue is not null begin
  693.    raiserror('Will now change your existing ''%s'' from %d to our recommendation of %d.',1,1 ,@ConfigName,@OldValue,@NewValue)
  694.    update sysconfigures set value=@NewValue where config=@ConfigNum
  695.                          end
  696.  
  697.  
  698. -------------------------------------------------------
  699. SELECT @NewValue=5000 ,@ConfigName='locks' ,@ConfigNum=106 ------------------
  700.  
  701. select @OldValue = min(cf.value) from sysconfigures cf ,spt_values val
  702.    where val.name=@ConfigName and val.type='C  ' and cf.config=val.number
  703.    and   cf.value < @NewValue
  704.  
  705. if @OldValue is not null begin
  706.    raiserror('Will now change your existing ''%s'' from %d to our recommendation of %d.',1,1 ,@ConfigName,@OldValue,@NewValue)
  707.    update sysconfigures set value=@NewValue where config=@ConfigNum
  708.                          end
  709.  
  710.  
  711. -------------------------------------------------------
  712. SELECT @NewValue=500 ,@ConfigName='open objects' ,@ConfigNum=107 --------------
  713.  
  714. select @OldValue = min(cf.value) from sysconfigures cf ,spt_values val
  715.    where val.name=@ConfigName and val.type='C  ' and cf.config=val.number
  716.    and   cf.value < @NewValue
  717.  
  718. if @OldValue is not null begin
  719.    raiserror('Will now change your existing ''%s'' from %d to our recommendation of %d.',1,1 ,@ConfigName,@OldValue,@NewValue)
  720.    update sysconfigures set value=@NewValue where config=@ConfigNum
  721.                          end
  722.  
  723.  
  724. -------------------------------------------------------
  725. SELECT @NewValue=20 ,@ConfigName='user connections' ,@ConfigNum=103
  726.  
  727. select @OldValue = min(cf.value) from sysconfigures cf ,spt_values val
  728.    where val.name=@ConfigName and val.type='C  ' and cf.config=val.number
  729.    and   cf.value < @NewValue
  730.  
  731. if @OldValue is not null begin
  732.    raiserror('Will now change your existing ''%s'' from %d to our recommendation of %d.',1,1 ,@ConfigName,@OldValue,@NewValue)
  733.    update sysconfigures set value=@NewValue where config=@ConfigNum
  734.                          end
  735.  
  736.  
  737. --------------------------------
  738. LABEL_36AFTERUPGRADE:
  739. --------------------------------
  740.  
  741. raiserror('At  LABEL_36AFTERUPGRADE  ....',1,1)
  742.  
  743.  
  744. Go
  745.  
  746.  
  747.  
  748. raiserror('
  749. Will now run the finalization logic for this file.
  750. ',1,1)
  751.  
  752. use master
  753. Go
  754.  
  755. if exists (select * from sysobjects where name = 'sp_configure'
  756.          and sysstat & 0xf = 4)
  757.    begin
  758.       exec sp_configure 'allow updates',0   --  102
  759.       reconfigure with override
  760.       raiserror('sp_configure just now turned off ''allow updates'', and reconfigure with override was run.',1,1)
  761.    end
  762. else
  763.    raiserror('(sp_configure not present to turn off ''allow updates''.)',1,1)
  764. Go
  765.  
  766. ---- The configuration changes made by this file might notbe fully installed until sqlservr.exe is stopped & restarted.
  767. Go
  768. ----(still need -m effect) reconfigure with override
  769. Go
  770.  
  771.  
  772. declare @vdt varchar(99)
  773. select  @vdt = convert(varchar,getdate(),113)
  774. raiserror('
  775. Finishing Configur.SQL at %s',1,1,@vdt)
  776. Go
  777.  
  778. dump transaction master with no_log
  779. Go
  780. checkpoint
  781. Go
  782. -- -
  783.  
  784.