SQL Server Performance

SQL Server Setup Script

Discussion in 'Contribute Your SQL Server Scripts' started by simondm, Feb 25, 2005.

  1. simondm New Member

    I recently had to install SQL on many many many identical machines. Needless to say I didn't fancy doing it all manually!

    The batch script does an unattended install of SQL 2000, then SP3a, then the latest hotfix. It then move the logs of the system DB's to another drive and runs a SQL script which does the internal configurations (memory, users etc) - I have not posted this scripted as it is too bespoke.

    You obviously need to set the paths and check the file names. You also need to record iss files for the original install and the service pack first. Make sure the paths are correct for these too.



    net use Y: "\MYSERVERScripts"
    net use X: "\MYSERVERSQL Setup Files"
    x:
    cd "sql2000stndx86setup"
    setupsql -s -f1 Y:miscSQL2000.iss
    cdcd "Service Pack 3ax86setup"
    @echo on
    start /wait setupsql.exe k=SMS -s -m -SMS -f1 Y:miscSP3a.iss
    @echo off
    cd..
    cd..
    start /wait X:MS03031.exe s /a /q
    C:
    reg add HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg2 /d -lE:DATAmastlog.ldf /f
    reg add HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg3 /d -T3608 /f
    NET STOP MSSQLSERVER
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamastlog.ldf" E:DATAmastlog.ldf
    NET START MSSQLSERVER
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_detach_db 'model'"
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamodellog.ldf" E:DATAmodellog.ldf
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_attach_db 'model', 'D:DATAMicrosoft SQL ServerMSSQLDatamodel.mdf', 'E:DATAmodellog.ldf'"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_detach_db 'msdb'"
    NET STOP MSSQLSERVER
    REG DELETE HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg3 /f
    NET START MSSQLSERVER
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamsdblog.ldf" E:DATAmsdblog.ldf
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_attach_db 'msdb', 'D:DATAMicrosoft SQL ServerMSSQLDatamsdbdata.mdf', 'E:DATAmsdblog.ldf'"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "Alter database tempdb modify file (name = templog, filename = 'E:data emplog.ldf')"
    NET STOP MSSQLSERVER
    NET START MSSQLSERVER
    DEL "D:DATAMicrosoft SQL ServerMSSQLData emplog.ldf"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -i "Y:DS ServersMyScript.sql" -o "C:ds_setup_log.txt"
    REG ADD HKLMSystemControlSet001ServicesMSSQLSERVER /v Start /t REG_DWORD /d 2 /f
    REG ADD HKLMSystemControlSet001ServicesSQLSERVERAGENT /v Start /t REG_DWORD /d 2 /f
    pause


    The pause is at the end so you can check for errors - just in case! The final two reg edits are to set SQL and the Agent to automatic startup.
  2. davesatibp New Member

    quote:Originally posted by simondm

    I recently had to install SQL on many many many identical machines. Needless to say I didn't fancy doing it all manually!

    The batch script does an unattended install of SQL 2000, then SP3a, then the latest hotfix. It then move the logs of the system DB's to another drive and runs a SQL script which does the internal configurations (memory, users etc) - I have not posted this scripted as it is too bespoke.

    You obviously need to set the paths and check the file names. You also need to record iss files for the original install and the service pack first. Make sure the paths are correct for these too.



    net use Y: "\MYSERVERScripts"
    net use X: "\MYSERVERSQL Setup Files"
    x:
    cd "sql2000stndx86setup"
    setupsql -s -f1 Y:miscSQL2000.iss
    cdcd "Service Pack 3ax86setup"
    @echo on
    start /wait setupsql.exe k=SMS -s -m -SMS -f1 Y:miscSP3a.iss
    @echo off
    cd..
    cd..
    start /wait X:MS03031.exe s /a /q
    C:
    reg add HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg2 /d -lE:DATAmastlog.ldf /f
    reg add HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg3 /d -T3608 /f
    NET STOP MSSQLSERVER
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamastlog.ldf" E:DATAmastlog.ldf
    NET START MSSQLSERVER
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_detach_db 'model'"
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamodellog.ldf" E:DATAmodellog.ldf
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_attach_db 'model', 'D:DATAMicrosoft SQL ServerMSSQLDatamodel.mdf', 'E:DATAmodellog.ldf'"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_detach_db 'msdb'"
    NET STOP MSSQLSERVER
    REG DELETE HKLMSoftwareMicrosoftMSSQLServerMSSQLServerParameters /v SQLArg3 /f
    NET START MSSQLSERVER
    MOVE "D:DATAMicrosoft SQL ServerMSSQLDatamsdblog.ldf" E:DATAmsdblog.ldf
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "EXEC sp_attach_db 'msdb', 'D:DATAMicrosoft SQL ServerMSSQLDatamsdbdata.mdf', 'E:DATAmsdblog.ldf'"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -Q "Alter database tempdb modify file (name = templog, filename = 'E:data emplog.ldf')"
    NET STOP MSSQLSERVER
    NET START MSSQLSERVER
    DEL "D:DATAMicrosoft SQL ServerMSSQLData emplog.ldf"
    "C:program FilesMicrosoft SQL Server80ToolsBinnisql.exe" -E -i "Y:DS ServersMyScript.sql" -o "C:ds_setup_log.txt"
    REG ADD HKLMSystemControlSet001ServicesMSSQLSERVER /v Start /t REG_DWORD /d 2 /f
    REG ADD HKLMSystemControlSet001ServicesSQLSERVERAGENT /v Start /t REG_DWORD /d 2 /f
    pause


    The pause is at the end so you can check for errors - just in case! The final two reg edits are to set SQL and the Agent to automatic startup.

Share This Page