Solved

View on several databases sql server 2005

Posted on 2007-03-17
6
164 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 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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