Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Alternative to Views

Author  Topic 

Lupison
Starting Member

5 Posts

Posted - 2010-08-25 : 12:20:05
Here's the basic problem.

I have 2 DBs. One contains a table. "DB1" & "DB2" DB2 can either reference D1.Table1 in it's stored procs etc, or it can choose to "override" that table and create that table inside itself (DB2.Table1) and use that in it's stored procs etc.

Other than a view, which would be horrendous in this case since the data is not going to be even close to being static, I was wondering if anyone knew of anything else I could use.

Or are views against a single table an "ok" thing now to do for a table with constantly changing data?

Basically I just need some sort of "pointer" object that when a stored proc calls it it points to the right table without the programmer having to change 100 store procs when it's decided the DB2 will override the table in DB1.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-25 : 12:38:21
Maybe what you want is a synonym.

quote:

Or are views against a single table an "ok" thing now to do for a table with constantly changing data?



Views can reference multiple tables via joins, etc... and have constantly changing data and still be fine.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lupison
Starting Member

5 Posts

Posted - 2010-08-25 : 12:49:39
quote:
Originally posted by tkizer

Maybe what you want is a synonym.

quote:

Or are views against a single table an "ok" thing now to do for a table with constantly changing data?



Views can reference multiple tables via joins, etc... and have constantly changing data and still be fine.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



I was always told that Views "recompile" thier data everytime a row changes in a table they reference. So that you only want Views against tables with very static data.
Go to Top of Page

Lupison
Starting Member

5 Posts

Posted - 2010-08-25 : 12:52:43
quote:
Originally posted by tkizer

Maybe what you want is a synonym.

quote:

Or are views against a single table an "ok" thing now to do for a table with constantly changing data?



Views can reference multiple tables via joins, etc... and have constantly changing data and still be fine.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



synonym appear to be perfect. Never heard of these before, they look very awesome even if I don't use them here.

thank you.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-25 : 13:33:40
A view needs to be recompiled if you are using select * in it and the schema changes.

There is no performance penalty of a constantly changing table inside a view. We use them quite heavily in one of my busiest systems.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

niechen861102
Starting Member

9 Posts

Posted - 2010-09-06 : 23:05:18
spam removed
Go to Top of Page
   

- Advertisement -