Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change user's default database using SQL for SQL Server 2000?

I tried:

ALTER LOGIN  user
WITH DEFAULT_DATABASE = defaultDB

but it says:

Line 1: Incorrect syntax near 'LOGIN'.

I know this works in 2005+ but is there a different way in 2000?

like image 255
Abe Miessler Avatar asked Feb 01 '11 01:02

Abe Miessler


People also ask

What is default database in SQL Server?

master - keeps the information for an instance of SQL Server. msdb - used by SQL Server Agent. model - template database copied for each new database.

How do I change user in database?

To change the user name of a user having CONTROL permission on the database requires the CONTROL permission on the database. To change the default schema or language requires ALTER permission on the user. Users can change their own default schema or language.

How do I change the default schema in SQL Server?

In that case, just use SQL Server Management Studio > Database > Security > Users > Properties and change the default schema there.


1 Answers

exec sp_defaultdb @loginame='someone', @defdb='dbname'

Or since there are only those 2 parameters,

exec sp_defaultdb 'someone', 'dbname'
like image 104
RichardTheKiwi Avatar answered Oct 12 '22 22:10

RichardTheKiwi