SQL Server 2005
In SQL Server 2005, you can use the sqlcmd utility to change the default database. To do this, follow these steps: ◆ 1. Click Start, click Run, type cmd, and then press Enter.
◆ 2. use one of the following methods based on the type of authentication used for SQL Server login: • If SQL Server login uses Microsoft Windows Authentication to connect to this instance, type the following at a command prompt, then press Enter:
The code is as follows: |
Copy code |
Sqlcmd-E-S InstanceName-d master |
• If you log on to SQL Server and use SQL Server authentication to connect to this instance, type the following in a command prompt and press Enter:
The code is as follows: |
Copy code |
Sqlcmd-S InstanceName-d master-U SQLLogin-P Password |
Note: InstanceName is a placeholder for the name of the SQL Server 2005 instance to be connected. SQLLogin is a placeholder for deleting the SQL Server logon of its default database. Password is a placeholder for the SQL Server login Password.
◆ 3. At the sqlcmd prompt, type the following content and press Enter:
The code is as follows: |
Copy code |
Alter LOGIN sa WITH DEFAULT_DATABASE = master |