Production principles of green SQL Server

Source: Internet
Author: User
Tags mssql mssqlserver

These texts are displayed in the Delphi box. The original author is lwp_lwp.
With the original address: http://www.2ccc.com/article.asp? ArticleID = 2717
This post is for reference only.

1. sqlservr.exe run parameters.

SQL Server can be started in the Windows service mode (default) or in the application mode. The following describes the parameters when sqlservr.exe is started as an application.
Sqlservr Application Usage:
Sqlservr [-sinstance_name] [-C] [-dmaster_path] [-F]
[-Eerror_log_path] [-lmaster_log_path] [-m]
[-N] [-ttrace #] [-V] [-x] [-G number] [-O] [-y number]
-Sinstance_name
Specify the SQL server instance to connect. If no instance is specified, sqlservr starts the default instance of SQL Server. Important when starting an SQL server instance, you must use the sqlservr application from the appropriate directory where the instance is located. For default instances, run sqlservr from the/MSSQL/binn directory. For named instances, run sqlservr in the/MSSQL $ instance_name/binn directory.
-C
The SQL Server instance is started independently of the Windows NT Service Control Manager. When you start sqlserver from a command prompt, you can use this option to shorten the time to start SQL Server. (Note: When this option is used, you cannot stop SQL server by using the SQL Server service manager or the net stop command, and if it has been removed from Microsoft Windows NT? If the system logs out, SQL server stops running .) -Dmaster_path indicates the completely valid path of the master database file. There is no space between-D and master_path.
-F
Start the server in the minimal configuration mode. Then, the system administrator can reconfigure the configuration options (using sp_configure system stored procedures ).
-Eerror_log_path
Indicates the path of the error log file. If no path is specified, the default instance is X:/program files/Microsoft SQL Server/MSSQL/log/errorlog, and the default instance location is X: /program files/Microsoft SQL Server/MSSQL $ instance_name/log/errorlog. There is no space between-E and error_log_path.
-Lmaster_log_path
Indicates the path to the transaction log file of the master database. There is no space between-L and master_log_path.
-M
The SQL Server instance is started in single-user mode. If SQL Server is started in single-user mode, only one user can be connected. The checkpoint mechanism (which ensures that completed transactions are regularly written to the database device from the disk cache) will not start. (This option is generally used if you encounter System database problems that need to be fixed .)
-N
Indicates that you do not want to use Windows NT application logs to record SQL Server events. If you use the-n option to start an SQL server instance, you are advised to use the-e option as well. Otherwise, SQL Server events will not be recorded.
-Ttrace #
Indicates that the specified trace # should be used to start the SQL server instance. The trace flag is used to start a server with non-standard behaviors. For more information about available trace tags (trace #), see trace tags. Important when a trace flag is specified, use-t to pass the trace flag number. SQL Server accepts lowercase letters T (-T). However,-t also sets other internal tracking tags required by SQL Server Support Engineers.
-V
The server version number is displayed.
-X
Disable CPU maintenance statistics.
-G memory_to_reserve
The MB integer of the specified memory. The memory is retained for other applications running within SQL Server 2000 (in-process.
-O
Disable heterogeneous queries by specifying that Distributed COM (DCOM) is not required.
-Y error_number
If SQL Server 2000 encounters an error message specified in this option, it writes the appearance stack trace to the error log. You can use multiple-y parameters to specify multiple errors.

2. System database Path Problems.
Generally, after SQL Server is installed normally, the paths of System databases such as Master are set to absolute paths. To correct the paths of databases as relative paths, you can use the following SQL statement:
SQL: = format ('Update sysaltfiles set filename = '% s' where filename =' % s '',
['./../Data/' + extractfilename (mdffile), mdffile]);
Adoquery1.close;
Adoquery1. SQL. Text: = SQL;
Adoquery1.execsql;
SQL: = format ('Update sysaltfiles set filename = '% s' where filename =' % s '',
['./../Data/' + extractfilename (logfile), logfile]);
Adoquery1.close;
Adoquery1. SQL. Text: = SQL;
Adoquery1.execsql;
SQL: = format ('Update sysdatabases set filename = '% s' where name =' % s '',['. /.. /data/'+ extractfilename (mdffile), edit1.text]);
Adoquery1.close;
Adoquery1. SQL. Text: = SQL;
Adoquery1.execsql;
Open the sysaltfiles table and sysdatabases. In addition to the system database, other databases can also use this method to change to the relative path.
The advantage of using relative paths is that you can copy your green SQL Server to any directory or any other machine at any time, and all the original databases can be used, if it is an absolute path to another machine, it will not work.
3. Registry problems:
You can refer to the following registry file
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name]
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer]
"Auditlevel" = DWORD: 00000000
"Defaultlogin" = "guest"
"Listenon" = hex (7): 53,00, 53,00, 4D, 53, 4E, 54, 00, 4C, 00, 00
"Loginmode" = DWORD: 00000000
"Map _" = "//"
"Map #" = "-"
"Map $" = ""
"Sethostname" = DWORD: 00000000
"Tapeloadwaittime" = DWORD: ffffffff
"Uptime_pid" = DWORD: 00001044
"Uptime_time_utc" = HEX: 26,57, C8, B3, FB, BB, C5, 01
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer/CurrentVersion]
"CurrentVersion" = "8.00.194"
"Registeredowner" = ""
"Serialnumber" = ""
"Csdversionnumber" = DWORD: 00000300
"Csdversion" = "8.00.761"
"Language" = DWORD: 00000804
"Checksum" = HEX,, 63, listen, 37,36, 30,35, 65,32, 66,34, 66,31, 33,63, 39,33, 63,34, 66,62, 66,34, middle, 38, middle, 35,34, 37,33, 35,39, 35,32, 36,63,, 63, 64, 34, 65, 61, 32, 36, 64, 65, 66,66, 00
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer/parameters]
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer/supersocketnetlib]
"Protocollist" = hex (7):, 00, 00, 00
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer/supersocketnetlib/NP]
"Pipename" = "[url =] //. // pipe // MSSQL $ name // SQL // query [/url]"
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/MSSQLServer/supersocketnetlib/tcp]
"TcpHideFlag" = DWORD: 00000000
"Tcpdynamicports" = "$ port"
"Tcpport" = "$ port"
[HKEY_LOCAL_MACHINE/software/Microsoft SQL Server/$ name/setup]
"Featurename" = "sqlrun"
"Firststart" = DWORD: 00000000
"Productcode" = "{E09B48B5-E141-427A-AB0C-D3605127224A }"
"Sqldataroot" = "$ path"
"Sqlpath" = "$ path"
This is the registry used to register an SQL server instance. Replace $ name, $ path, and $ port with your defined Instance name, all the paths of the current program, and the listening port, then, import the registry.
4. Start SQL Server

Ipath: = extractfilepath (application. exename );
CommandLine: = pchar (ipath + 'binn/sqlservr.exe-D. /.. /data/master. MDF-L. /.. /data/mastlog. LDF-e. /.. /log/log.txt + edit1.text );
CreateProcess (
Nil,
CommandLine,
Nil,
Nil,
True,
Create_no_window,
Nil,
Pchar (ipath + 'binn /'),
Startupinfo,
Processinformation
)
You can also directly write a. Bat command to run it.
5. startup log problems.
This is the simplest question. Because a log file is specified when sqlservr.exe is executed, you can use only one timer (50 ms) to read the file and display the startup log in the program, you can find a specific solution.
6. Stop the service
Use CreateProcess to get the process ID. terminateprocess closes the SQL server process and the service stops.

Based on the above six steps, you can handle a green SQL Server by yourself, and you can sort out all the green SQL Server versions based on different SQL Server versions.
Green SQL Server Enterprise Edition
Green SQL Server Personal Edition
Green MSDE
......
In this way, all operating systems will be handled in the future.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.