Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari iniPelayar ini tidak lagi disokong.
Naik taraf kepada Microsoft Edge untuk memanfaatkan ciri, kemas kini keselamatan dan sokongan teknikal yang terkini.
Applies to:
SQL Server
Changes the default database for a SQL Server login.
Penting
This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER LOGIN instead.
Transact-SQL syntax conventions
sp_defaultdb
[ @loginame = ] N'loginame'
, [ @defdb = ] N'defdb'
[ ; ]
The login name. @loginame is sysname, with no default. @loginame can be an existing SQL Server login or a Windows user or group. If a login for the Windows user or group doesn't exist in SQL Server, it's automatically added.
The name of the new default database. @defdb is sysname, with no default. @defdb must already exist.
0
(success) or 1
(failure).
sp_defaultdb
calls ALTER LOGIN
, which supports extra options. For information about changing default database, see ALTER LOGIN.
sp_defaultdb
can't be executed within a user-defined transaction.
Requires ALTER ANY LOGIN
permission.
The following example sets AdventureWorks2022
as the default database for SQL Server login Victoria
.
EXEC sp_defaultdb 'Victoria', 'AdventureWorks2022';
Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari ini