Possible to set default schema from connection string?

Earlz picture Earlz · Jul 19, 2010 · Viewed 76.8k times · Source

With SQL Server 2005 and 2008 is it possible to set the default schema from the connection string? It'd be a lot easier if we didn't have to manually set the schema with SQL code.

Answer

OMG Ponies picture OMG Ponies · Jul 19, 2010

You set the default schema based on the user who is logging in via the connection, not the connection itself.

ALTER USER Mary51 WITH DEFAULT_SCHEMA = Purchasing;

Reference: