Solved

View on several databases sql server 2005

Posted on 2007-03-17
6
182 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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.

617 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