469,283 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

Set default schema in code - possible?

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
1 4459
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.

Similar topics

1 post views Thread by indo3 | last post: by
4 posts views Thread by Lénaïc Huard | last post: by
4 posts views Thread by Hemant Shah | last post: by
1 post views Thread by Nalaka | last post: by
1 post views Thread by Plop69 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.