Solved

View on several databases sql server 2005

Posted on 2007-03-17
6
157 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
6 Comments
 
LVL 69

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now