all groups > sql server (alternate) > september 2007 >
You're in the

sql server (alternate)

group:

Set default schema in code - possible?


Set default schema in code - possible? aj
9/27/2007 9:44:20 AM
sql server (alternate): ==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

Re: Set default schema in code - possible? Erland Sommarskog
9/27/2007 9:46:42 PM
aj (ronald@mcdonalds.com) writes:
[quoted text, click to view]

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, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button