By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

Set default schema in code - possible?

P: n/a
aj
==SQL Server 2005 SP2==

Is it possible to set the default schema in code?

I know that, for a particular DB user, I can set the default schema
statically in Mgmt Studio. However, I want to do this dynamically
in source code.

I am using JDBC if that matters.

Any help appreciated.

TIA

aj
Sep 27 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
aj (ro****@mcdonalds.com) writes:
Is it possible to set the default schema in code?

I know that, for a particular DB user, I can set the default schema
statically in Mgmt Studio. However, I want to do this dynamically
in source code.
You can change the default schema for a user with ALTER USER. Look in
Books Online for details. Or use the Script button in SSMS to see how
Mgmt Studio do it.

Whether it is a good idea is another matter. If you are writing an admin
application, I guess it's OK. But if you are considering changing the
schema of the current user on the fly, keep in mind that it will affect
all sessions for that user.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Sep 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.