Solved

View on several databases sql server 2005

Posted on 2007-03-17
6
181 Views
Last Modified: 2010-03-19
Is there a way to create a view in one database that combines tables from several databases.  What I'm trying to do is this:
Since my database has huge amounts of data, I want to split out by year, since data from previous years is seldom changed, then it isn't in the curent database.
But sometimes users like to report on old data.  What I would like to do is have a view which combines the data and when I report, use this view as opposed to the table which only hold current data.
Does this make sense, or has someone done something similar?
0
Comment
Question by:Fraser_Admin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 18740996
you can use the following syntax:

select * from dbname.dbo.tablename
union
select * from otherdbname.dbo.tablename
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18741110
yes perfectly possible,

you may also like to examine/consider distributed/partitioned views if you can organise a partitioning key/range

just use the 3/4 part name to reference the tables...

servername.databasename.ownername.tableorVieworfunctionName
0
 

Author Comment

by:Fraser_Admin
ID: 18741407
lowfatspread, i'm not sure what you are suggesting?  what are distributed/partitioned views. and what is key/range.  is there a better/more efficient way of doing this than the method emoreau suggested above?  i'm looking for the method that returns the data quickest.  right now i have several hundred thousand records in a table which is from 2003 - Now.  It is sometimes slow running queries, so I would like to try splitting by year.  Maybe there is a better solution for me (ie. indexing??)  I've tried indexing before, but when I show the execution plan, it never seems to use my index.  Perhaps I'm doing something wrong....
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18746737
partitioned views are a way of allowing you to split your data across diferent tables even different databases and servers to imprve overal performance....

the method eventually comes down to defining a view similar to emoreaus... however because you have defined a partitoning key (a range..) which effectively constrain the data to 1 partiton (table) sql server just accesses the
table it requires....


several hundred thousand rows doesn't sound that large...

i'd expect your problems to be better address with index changes....

what are your current indexes ?
what are your queries like?

 
0
 
LVL 1

Expert Comment

by:engayman01
ID: 18746944
Hi,
Just named your database in the query.
databaseName.dbo.TableName.

Best Regards
0
 

Author Comment

by:Fraser_Admin
ID: 18775627
I am having problems putting new indicies.  It times out.  I'm not even sure I completely understand how they work.  I have developed a scaling system.  I track bill number, contract information, product information, payment information, etc.  Mainly on 3 different data tables, and several lookup tables.  So most of my fields are integer values referencing lookup tables.

I only have my primary key on the table right now.

How do you go about deciding what to use as an index.  I would think common queries would be a good idea.  ie. if people generally want to show the weights delivered based on contract, would I make an index based on the contract and weight?

One example report would be delivery date entered by user and a result is sumed weights by contract.

Hopefully you understand my question.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question