Views Across Databases

Jul 20, 2005

Hi,
I am trying to locate documentation on using views across databases.
We have serveral databases broken down by application, some shared
databases and some location specific databases supporting multiple
facilities using the applications. The DBA for our client is the one
that set up the topology of these databases but I don't understand the
performance considerations of having views in an applictation database
referencing tables in the shared databases. Is the enitre table
copied to tempdb when the view is referenced? How does indexing in
the containing database affect access through the view? These are
some of the questions I would like see documenation on.

Thanks,
Jim

View 3 Replies


ADVERTISEMENT

Views Across Databases On The Same Server

Apr 25, 2000

I have two databases on my Server - database1 and database2.
Database1 has a view on tables on database2 :
create view myview as select * from database2.dbo.tablename
(because all tables in database2 are owned by dbo)
and myview on database1 is owned by dbo.
when a user on database1 - lets say user1 tries to select rows from myview,
we get an error saying that user1 is not a valid user on database2.
it only allows user1 to select rows from myview if i make user1 a user on database2
as well, which is not what i want.
Can someone please point me in the right direction.
i would like to be able to select rows from a view which is based on tables in another database.
thanks
simran

View 5 Replies View Related

Moving Views To Other Databases

Sep 27, 2005

Hi

I have a few views i created in a database.I want them to be moved to another database with credentials like dbo.dsatabasename.tablename automatically adding up to the new views.
How can i do that

Vic

Vicky

View 3 Replies View Related

Finding All Views With A Specific Name, In All Databases

Nov 17, 2006

Hi,

We are migrating to SQL Server 2005 from 2000 and we have a view created in many of our databases. That view must be changed after the migration because it uses system tables and does not return the correct information in SQL Server 2005.

To do that, I want to create an SSIS-package that loops through all the databases on a particular server. If that view exists in the database, I want to run a script that change the view.

What I try to do:

Set up a For Each Loop container with Foreach SMO Enumerator
Set the connection to my server
Set the Enumerate property to "SMOEnumObj[@Name='Databases']/SMOEnumType[@Name='Names']"
On the Variable Mapping page, place Index 0 in Variable User::dbName
In the For Each Loop, place a script task to msgbox the value of User::dbName

This all works good. The problem comes when I try to nest the For Each Loop

Inside the "For Each Database Loop", place a new For Each Loop container with Foreach SMO Enumerator
I connect the Msgbox Script Task with the new For each loop
Use the same connection
Set the EnumURN property in the Expression Builder to "Database[@Name='" + @[User::dbName] +"']/SMOEnumObj[@Name='Views']/SMOEnumType[@Name='Names']"
On the Variable Mapping page, place index 0 in Variable User::tabName
In the For Each Loop, place a script task to msgbox the value of User::tabName

When I try to run the package now, it does not at all.

In my Progress tab I see that Validation has started and completed for each task, but I see now errors. Nothing has run.

Test 1: I change the DelayValidation for the Inner Loop to True

Now the package runs, but I never get to the script task in the inner loop.

Question 1: What's the problem?

Question 2: Is there another way to do this?

Regards

Magnus

View 6 Replies View Related

Table Views Over Multiple Databases

Apr 20, 2006

Hi champs!

Is it possible to make a database View over two different database installations on different machines?



Many thanks

kurlan

View 4 Replies View Related

Dependencies Among Views And A Table In Different Databases

Aug 20, 2007

Hi everybody.
I need to find all the views that depend on a table in a different database, in order to refresh them once the table is altered.

In the BOL I found the following script that is very useful, but I can't use it if the view and the table are in different database.
Where can I find the dependencies in this case?

Thank you very much.


ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/9ce1d07c-ee66-4a83-8c73-cd2cc104dd08.htm
Creating a script that updates all views that have dependencies on a changed object.USE AdventureWorks;
GO
SELECT DISTINCT 'EXEC sp_refreshview ''' + name + ''''
FROM sys.objects so INNER JOIN sys.sql_dependencies sd
ON so.object_id = sd.object_id
WHERE type = 'V'
AND sd.referenced_major_id = object_id('Person.Contact')

View 1 Replies View Related

SQL Svr 2005 - Use Same Stored Proc && Views For 2 Databases?

Jan 10, 2007

I am moving a fairly large app from Access 2003 to C#/SQL Server 2005.

The app has one front end mde, but it has two backend data mdbs, one is used in the US and one in the UK.

The two backend mdb's are identical in structure, but of course the data is different. There are 150 tables or so, and we plan to maintain separate databases after the upgrade.

Now, of course, all of the queries are in the front end, the backend db's contain only tables.

In the new world, I do not want to have to maintain the same views and stored procs in two different SQL Server databases.

Is there a way to have all views and stored procs in one database, but have them draw on the data in the two other databases. There must should be a way to deal with this scenario in SQL Server.

Many thanks
Mike Thomas

View 5 Replies View Related

SQL Server 2014 :: Query For Listing Views In A Database Involving Tables From Other Databases?

Oct 19, 2015

script to get the list of views in a database, involving tables from other databases?I AM using SQL server 2014

View 2 Replies View Related

Are Embedded Views (Views Within Views...) Evil And If So Why?

Apr 3, 2006

Fellow database developers,I would like to draw on your experience with views. I have a databasethat includes many views. Sometimes, views contains other views, andthose views in turn may contain views. In fact, I have some views inmy database that are a product of nested views of up to 6 levels deep!The reason we did this was.1. Object-oriented in nature. Makes it easy to work with them.2. Changing an underlying view (adding new fields, removing etc),automatically the higher up views inherit this new information. Thismake maintenance very easy.3. These nested views are only ever used for the reporting side of ourapplication, not for the day-to-day database use by the application.We use Crystal Reports and Crystal is smart enough (can't believe Ijust said that about Crystal) to only pull back the fields that arebeing accessed by the report. In other words, Crystal will issue aSelect field1, field2, field3 from ReportingView Where .... eventhough "ReportingView" contains a long list of fields.Problems I can see.1. Parent views generally use "Select * From childview". This meansthat we have to execute a "sp_refreshview" command against all viewswhenever child views are altered.2. Parent views return a lot of information that isn't necessarilyused.3. Makes it harder to track down exactly where the information iscoming from. You have to drill right through to the child view to seethe raw table joins etc.Does anyone have any comments on this database design? I would love tohear your opinions and tales from the trenches.Best regards,Rod.

View 15 Replies View Related

Large Views Vs Multiple Small Views

Sep 6, 2007

Which is more efficient? One large view that joins >=10 tables, or a few smaller views that join only the tables needed for individual pages?

View 1 Replies View Related

Recompiling Views That Reference Other Views

Jun 28, 2007

Hello.

Newbie here. I've only been using SQL for about a year now and have some minor questions about sql objects that reference other objects.



We have some views which reference other views in the joins. I will call one the primary view and the one being referenced in the joins as the secondary view.

Recently we made changes to the secondary view.

After which the primary views which referenced it would not work because of this change and had to be 'refreshed' by using drop/create scripts which essentially just dropped it and recreated the exact same view. I do not recall the exact error message that was returned other than it seemed to suggest that it could no longer see the secondary view since it had been changed. Nothing in the primary view was changed in any way, just the secondary.



Some here where I work have suggested off hand that this was a recompile of the primary view because the contents of the secondary changed.

My questions are:

1. Exactly why did this happen and is there a proper name for it when it does?

2. The same problem does not seem to occur when we have stored procedures referencing views in the joins which had just been changed. Why is that?



Thanks for any help on the matter. I greatly appreciate it.

View 3 Replies View Related

Quicky : Views Of Views Of Views

Feb 22, 2007

Hello,

to make a report easier I'm developing it using a view of joined views of joined views.

Is there any significant performance penalty as opposed to just having one big select?

Cheers.

View 1 Replies View Related

Views Dependent On Other Views

Mar 14, 2006

Hello There,I'm trying to create a view that has calculations dependent oncalculations, where the problem resides is that each time I make acalculation I must create an intermediate view so I can reference aprevious calculation.for example lets say I have my_table that has columns a & b. now I wanta view that has a & b, c = a + b, and d = c + 1.this is grossly simplified, the calculations I actually use are fairlycomplex and copying / pasting them is out of the question.so what I have is my_view_a which makes column c, and my my_view_finalwhich makes column d (however, in my real application I have 5 of theseviews, a/b/c/d/e/)is there anyway I can consolidate all these views into one? I wasthinking of using a stored procedure with temp tables or somethingalong those lines.I just which I can use the aliases that I create for c in d in onestep.any insight would be greatly appreciated.

View 5 Replies View Related

Linking Tables From Different Databases Or Querying From Multiple Databases

Dec 10, 2007

Dear Readers,Is it possible, like in Access, to link to tables in other SQL databases that are on the same server? I have a query that I originally had in Access that queered from multiply databases. It did this by having those other tables in the other databases linked to the database that had the query. 
 

View 3 Replies View Related

Service Broker Not Working For Restored Databases (SQL 2000 Databases Restored On 2005)

Jan 24, 2006

I just restored my SQL server 2000 database on the SQL server 2005. after this i ran the Service broker sample ("Hello World") on this database by changing the AdventureWorks name to the new database name. The "setup.sql" runs fine. When i run the "SendMessage.sql" i was not getting any rows in the output (The message was not getting inserted into the queue). I checked the Service broker is enabled on this databased using the query "select is_broker_enabled from sys.databases where name = 'newdbname' " It was 1. I even tried the ALTER DATABASE SET ENABLE_BROKER. but it didnt work.

When i tried the sample on a newly created database it worked fine.

Is there any solution to make the restored database to work for service broker.

Thanks

Prashanth

View 3 Replies View Related

Copying Databases Between Databases

Feb 8, 2000

hi from France !!!

i would like how to duplicate a database to another server with all datas, constraints, keys, indexes...
should i use sp_attach_db, dts, backup/restore, sql scripts... ???

thanks to all, nico

View 1 Replies View Related

Can Some One Help Me With SQL VIEWS

Apr 15, 2008

Hi everyone,                    I have a problem like this . I have tables Coursegroupcode, which has groupname, codeI have Courses That has Coursename, its code(group code),Term, Course Number Enrollment table which has Foreign keys Term,Course NUmber , SSN     I need to get a view like thisI should list all the coursecodes and people enrolled for each course code for selected terms  Course Table Primary keys(TERM,COUSE Number)Enrollment Table(Foreign keys) TERM ,COURSE NUMBER, SSNplease help 

View 9 Replies View Related

Sql Views

Apr 7, 2005

 Hi!
I need to know if i can build an aspx file on top of an sql view? I
can only see my tables when i connect to the database....
Collette.

View 3 Replies View Related

SQL Views

Oct 18, 2005

Can SQL Views insert to the tables they are created from?I have a database that is not well structured. It has a lot of redundency. What I want to do is create a SQL View that brings in all the data I need and have my application use that new SQL View instead of the data tables. Then I want to be able to insert new information to a SQL View that actualy gets inserted into the tables that the SQL Viewer is created from.Can this be done?Does this make any sense?

View 1 Replies View Related

Views

Mar 26, 2001

I have a query which unions the four select statements.....

the select statements are joined with other tables and views.....


When i execute the query i get ODBC timeout error........

But the strange thing is that if i execute the view individually once and again execute the query it works fine.......and later it justs works fine....

Can anyone tell why is it like that.......

Thanks,
Sajai.

View 1 Replies View Related

SP's And Views

May 23, 2000

Is there a performance hit running a sp against a view versus a base table. The view just excludes
several of the records based on some criteria, and all the data I will be retreiving is included in
the view. Or should I just stick my criteria in the SP to exclude the data?

View 1 Replies View Related

Iif Views

Jun 19, 2000

Is there a way to imbed "iif"-like logic in a SQL view? "case when" works in regular queries, but apparently is not supported in views...

View 1 Replies View Related

Views

Aug 14, 2002

I have some rather complex views to work with. Do they slow you down? Would it be better to move a view into a stored procedure? Is there any difference between these three solutions?
<B>1.Using views:</b>
Create view X
As
Select Col1, Col2, Col3 from Table1
Go

Create view Y
As
Select Col1, Col2, Col3 from Table2
Go

Create proc Z
As
Select X.Col2, X.Col3, Y.Col2, Y.Col3
From X inner join Y on X.Col1 = X.Col1
GO

<b>2.Using just a stored proc:</b>
Create proc Z
As
Select X.Col2, X.Col3, Y.Col2, Y.Col3
from
(Select Col1, Col2, Col3 from Table1) X inner join
(Select Col1, Col2, Col3 from Table2) Y on X.Col1 = Y.Col1

<b>.Joining tables</b>
Create proc Z
As
Select Table1.Col2, Table1.Col3, Table2.Col1, Table2.Col3
FromTable1 inner join Table2 on Table1.Col1 = Table2.Col1
go

Thank you!

View 1 Replies View Related

VIEWS

Aug 1, 2001

I am struggling with setting up views in SQL Server 7.0 and 2000. What types of views are available.

I have one database with 112 tables and 2308 fields.

Thanks in Advance

View 1 Replies View Related

Views

Jun 9, 2004

I have created a database connected to a GUI using VB 6.0. When editing the views from the front end, do the tables also get updated


Thanks

View 3 Replies View Related

Views ?

Aug 17, 2004

Hi,

Is there a way to create a view with read only option. i.e the view should not allow the user to perform insert, update or delete action on it.

Please advise,

Thanks,
Sam

View 1 Replies View Related

MS SQL Views

Dec 23, 2004

Is there any kind of lock on a view in ms sql database?

what happens if one of my users is looking at the view and another one is adding something to the database?

Thanks.

View 3 Replies View Related

SQL Views

Sep 26, 2005

My First time building "Views" in SQL...... I'm trying to figure out how to return a 1 instead of a two when I Count the number of records that return inn my view.

here's what I have;

SELECT TOP 100 PERCENT dbo.tbl_ProcTimesheet.idCalendar, dbo.tbl_ProcTimesheet.erNum, dbo.tbl_ProcTimesheet.PayDate,
COUNT(dbo.tbl_ProcTimesheet.TransAmt) AS Shifts, dbo.tbl_ProcTimesheet.[Employee Number], dbo.tbl_ProcTimesheet.YCode,
dbo.tbl_ProcTimesheet.XCode, dbo.tbl_ProcTimesheet.ZCode, dbo.tbl_ProcTimesheet.eeLink
FROM dbo.tbl_ProcTimesheet INNER JOIN
dbo.tbl_SysVarRestEeShiftPayCodes ON dbo.tbl_ProcTimesheet.Code = dbo.tbl_SysVarRestEeShiftPayCodes.PayCode INNER JOIN
dbo.tbl_SysVarRestEeShiftRules ON dbo.tbl_ProcTimesheet.YCode = dbo.tbl_SysVarRestEeShiftRules.YCode AND
dbo.tbl_ProcTimesheet.ZCode = dbo.tbl_SysVarRestEeShiftRules.ZCode
WHERE (dbo.tbl_ProcTimesheet.Sequence <> N'0') AND (dbo.tbl_ProcTimesheet.Week < 3)
GROUP BY dbo.tbl_ProcTimesheet.idCalendar, dbo.tbl_ProcTimesheet.erNum, dbo.tbl_ProcTimesheet.PayDate, dbo.tbl_ProcTimesheet.TransAmt,
dbo.tbl_SysVarRestEeShiftRules.DailyHours, dbo.tbl_ProcTimesheet.[Employee Number], dbo.tbl_ProcTimesheet.XCode,
dbo.tbl_ProcTimesheet.YCode, dbo.tbl_ProcTimesheet.ZCode, dbo.tbl_ProcTimesheet.eeLink, dbo.tbl_ProcTimesheet.Sequence,
dbo.tbl_ProcTimesheet.Week
HAVING ('IIf' > '1,1,0') AND ('if' > '1,1') AND (dbo.tbl_ProcTimesheet.erNum LIKE N'5648 ') AND (SUM(dbo.tbl_ProcTimesheet.TransAmt)
>= dbo.tbl_SysVarRestEeShiftRules.DailyHours) AND (dbo.tbl_ProcTimesheet.PayDate = CONVERT(DATETIME, '2005-09-06 00:00:00', 102)) AND
(COUNT(dbo.tbl_ProcTimesheet.TransAmt) > 0)
ORDER BY dbo.tbl_ProcTimesheet.PayDate, dbo.tbl_ProcTimesheet.[Employee Number]

When it counts shifts, I only want to return a maximum of i, as in either you had a shoft that day, or not. I gave up trying to figure out the "IF" string in SQL, and for the life of me I can not figure this out.

Does anyone know a good site with info on how to construct an SQL View?

View 12 Replies View Related

Views

Jun 1, 2004

Hi,

I'm creating a stored procedure that will Drop all views when executed, this is what i have...

DECLARE crsViews CURSOR FOR
SELECT
name AS strViews
FROM

__________ <what do i put here?

WHERE
type ='U'
AND NAME LIKE'V%'


Thanks for any help!

View 2 Replies View Related

Views

Apr 21, 2008

MS SQL Server 2005
What happens if 2 or more users use the same View at the same time or while other user is using it, normally from Crystal Reports 10
It rebuilds again? Or?

Thanks

View 2 Replies View Related

Views On Views

Apr 25, 2008

Hi,

I have a SQL server: SQL2005
2 databases
db_repl: contains replicated data from mainframe
db_my: my database

db_my.vwRepl_WorkOrders: Select 1,2,3 from db_repl.dbo.WorkOrders
db_my.vwWorkOrdersOpen: select 1,2,3 from db_my.vwRepl_WorkOrders where Status=1

which approach is more optimal to do in order to find open work orders from Texas:
[select 1,2,3
from db_repl.dbo.workOrders where Status=1 and State=1
or
select 1,2,3
from db_my.vwWorkOrdersOpenwhere where State=1]
Is it best practice to use 'subviews' that acess db_repl directly or acess views in my_db that acess db_repl (2 hops or more if views call other views that call other views) Answer might be the obvious but just in case I am missing something here .
Thanks!

View 2 Replies View Related

Need Help On VIEWS

Apr 17, 2007

Can someone tell me when I would get an error like the one below:
"Update or insert of view or function failed because it contains a derived or constant field."

Here is how I create a VIEW

CREATE VIEW vSample
AS
SELECT ilm.ITEM_ID,
CAST (ilm.CURRENT_QUANTITY AS INT) CURRENT_QUANTITY
FROM SAMPLE_1 AS ilm INNER_JOIN SAMPLE_2 AS ilm2
on ilm.ID = ilm2.ID

Now, I am trying to update data using the view
UPDATE [vSample] SET [CURRENT_QUANTITY] = 598.00 WHERE (1 = 1)

I have tried casting the number 598.00 as int and no luck.
Can someone please help or guide me on this problem?

Thanks,
Javid

View 4 Replies View Related

What Can I Do With Views

Nov 6, 2007

Hello,

I am kind of new to using views. What types of queries can i use with view (i.e. select, insert, update, delete) in mssql 2000?

DigitalSolvers
Yahoo: DigitalSolvers
MSN Live: lew26@msn.com
Skype: DigitalSolvers

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved