0

I have a database that has been transfered from another server and has the schema careinflg. However my C#.net web application looks for objects with the schema dbo. Without manually altering every statement in my application is there anyway to point at careinflg by default?

I would prefer to do this in the C# layer if possible as the database is on a development server where it would be unwise to alter to the user properties themselves - but I can if there isn't another way.

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
tracer tong
  • 543
  • 6
  • 16

1 Answers1

0

When creating, altering and referencing objects, you should always specify the schema, regardless of whether you are using dbo or any other schema.

You can probably change the way your app currently behaves by changing the default schema for that user:

USE your_db;
GO

ALTER USER app_user_name
  WITH DEFAULT_SCHEMA = careinflg; -- this is a terribly unreadable name, btw

But this is not a fix and may have other undesired consequences (for example, when your application creates objects). You need to make a conscious effort to always use two-part names for objects.

Community
  • 1
  • 1
Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490