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
ADVERTISEMENT
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
Dec 1, 2007
I need to write a code for remove dependencies between Table1.Prikey and Table2.Idand add dependencies between Table1.Prikey and Table3.Id how to write the code? please help .. thank you very much
View 2 Replies
View Related
Aug 7, 2006
Hello,
I have a table in my SQL2000 server and there's a field in this table being created by an object - with a GREEN PLUS sign (look like an APPEND query in MsAccess). How can I locate and edit/modify that (append query-like) object within my SQL 2000 - Enterpise Manager? Here's some more details:
Table: Customer
Field1: CustomerID
Field2: CustomerRegion_ID (contains the ID above & RegionID below)
Table: Region
Field: Region_ID
--------------------------------------------------------------
When I checked on the dependencies of the table "Customer" I saw 1 dependency and this dependency has 2 table depend on it back-to-back (Customer & Region).
I want to modify the "Field2" of the "Customer" table and I looked everywhere on my VB/stored-procedure codes but couldn't find what triggle the creation of the field. The only thing that I suspect that would be the append object with "GREEN PLUS" sign. Any help would be appreciated.
Peter.
View 1 Replies
View Related
Nov 3, 2006
Hi
Is there any way to know as what are all the entities or objects which are dependent upon a given Table? I wanted to know if i update a particular table in a given database on a server, what are all the other tablesobjects which gets effected because of this updation, may be because of some update triggers defined on this tabl or through cascading updates etc. Any system stored procedure which can help me to know these dependencies.
Many Thanks in Advance!
View 4 Replies
View Related
Jul 20, 2005
Hi,I am trying to locate documentation on using views across databases.We have serveral databases broken down by application, some shareddatabases and some location specific databases supporting multiplefacilities using the applications. The DBA for our client is the onethat set up the topology of these databases but I don't understand theperformance considerations of having views in an applictation databasereferencing tables in the shared databases. Is the enitre tablecopied to tempdb when the view is referenced? How does indexing inthe containing database affect access through the view? These aresome of the questions I would like see documenation on.Thanks,Jim
View 3 Replies
View Related
Mar 6, 2008
Hi folks ...
I am back with another quick question here.
I was working on a table and on my absence it was dropped by one of my collegues. I restored it from the backup. The problem is it is not showing all the stored procedures and other tables under show dependencies as the original table was.
Is it going to affect the way the stored proc. depenendant on it works..or everything will be fine?
If the answer is yes...is there a way I can add the stored procedures or link it to the new table?
Thanks for reading and any insight is more than welcome.
Tanya
View 1 Replies
View Related
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
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
Dec 4, 2006
Hello,I have 3 tableTable 1 : list of "whatever" programTable 2: list of tasks for each programTable 3: list of user for each taskWhen I have a new program, I want to select existing task and copy them and assign them to my new program. But I also want to copy the list of user of each task.Is there a way to do that in sql?I do not really want to go through each single task, then copy it with the new program, then get the @@identity of the inserted task and then assign the same user to the newly inserted task.Thanks
View 3 Replies
View Related
Feb 27, 2007
Hi Foilks , I know it s easy question. I know databases but not SQL dbase. Please explain if you can.
what is "DEPENDENCIES" folder in sqlserver table mean please?
Dosston
View 8 Replies
View Related
Sep 12, 2001
Hello
I tried to execute sp_depends to get a list of Table dependencies
as when you click on "All tasks/Display dependencies" but I only get a few
not all of them.
Is there anybody who knows why I got only a part of the list
Thanks in advance
View 1 Replies
View Related
Jan 13, 2014
i have written query to find out column names of a table in the database .
SELECT t.NAME AS TABLEName
,SCHEMA_NAME(schema_id)+'.'+c.name AS ColumnName
FROM sys.tables t
INNER JOIN sys.columns c ON c.object_id = t.object_id
WHERE OBJECT_NAME(c.object_id) LIKE '%Message%'ORDER BY t.NAME
So far i got the Expected result but what ever column i am looking i want to find out the Dependency of column realted tables. by executing the above query i am getting table name and column name. How can i get the column related dependent tables.
View 1 Replies
View Related
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
May 17, 2006
Hi.I'm getting errors like this when I try to run an upgrade script I'm trying towrite/test:altering labels to length 60Server: Msg 5074, Level 16, State 4, Line 5The object 'ALTPART_ANNOT_ANNOTID_FK' is dependent on column 'label'.I used this to bracket my script:sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"gosp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER all"go/* updates here */sp_msforeachtable @command1="print '?'",@command2="ALTER TABLE ? CHECK CONSTRAINT all"gosp_msforeachtable @command1="print '?'",@command2="ALTER TABLE ? ENABLE TRIGGER all"goI guess the alter table nocheck constraint isn't disabling the fk'scompletely?Is there a way around this, or do I manually have to do the constraintdropping/recreating?ThanksJeff Kish
View 3 Replies
View Related
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
Aug 25, 2014
T-SQL script for the following request ?
Generate script for view dependencies of user defined table types ?
View 2 Replies
View Related
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
Aug 4, 2015
I would like to create a procedure which create views by taking parameters the table name and a field value (@Dist).
However I still receive the must declare the scalar variable "@Dist" error message although I use .sp_executesql for executing the particularized query.
Below code.
ALTER Procedure [dbo].[sp_ViewCreate]
/* Input Parameters */
@TableName Varchar(20),
@Dist Varchar(20)
AS
Declare @SQLQuery AS NVarchar(4000)
Declare @ParamDefinition AS NVarchar(2000)
[code]....
View 9 Replies
View Related
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
Dec 16, 2005
hi all
i am having problem in finding the max value of name in my views table
i have names stored in my table as view1,view2 etc, so what i wanted to do is i want to find the next max value of the name which obviously 3 so my new name will be view3
the problem is if some one already created a name as 'view of john' then i am running in to problem by using this statement
Code:
SELECT @viewcount=ISNULL(max(CAST(SUBSTRING(Name,5,len(Name)) AS Integer)),0)+1
FROM Views
WHERE Name LIKE 'View%'
SET @ViewName='View'+cast(@viewcount as varchar(8))
here is the sample data
Code:
create table Views(Name varchar(50))
insert into Views(Name)
values('View1')
insert into Views(Name)
values('View2')
insert into Views(Name)
values('View of John')
i hope any genius can guide me in solving the problem.
thanks in advance
View 1 Replies
View Related
Aug 11, 2004
Hi I am writting Stored Procedures that have to be built on the base of other tables specially created for this purpose, is it better to create these intermediate tables as views or as functions returning tables? I guess views would be lighter on performance as they would not be created on the fly?
View 2 Replies
View Related
Feb 2, 2006
Hi
I need to read a very big table more than 60,000 record but it is giving the following problem: But if it is small table there is no problem. Same problem also views.
Server Error in '/POBuilds' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
View 1 Replies
View Related
Apr 24, 2008
Are there any disadvantages in respect to performance in using table valued functions instead of using a view.
Thanks...
View 3 Replies
View Related
Feb 26, 2008
Hi Experts,
We have a very huge database that stores 12 years of data(120 Million records). But our application mainly accesses past 3 years data i.e , the queries would scan the 120 million records even when it actually has to scan 30 million records alone (for 3 years).
Since few other important applications needs access to all the 12 years data, we are in a position to have 12 years data in the same database.
Right now we are looking for an approach that would help us to efficiently access the 3 years data alone and boost the performance.
1. Will SQL server table paritioning help in this scenario ?
Or
2. Indexed views would help us ? Is it possible to create indexed views based on year range and access the views in the stored procedures ?
Any help would be greatly appreciated.
Thanks in advance,
Hariarul
View 4 Replies
View Related
Aug 8, 2005
I have a partitioned view sitting over several tables and I'm slowlyapproaching the 256 number. Can anybody confirm if there is such alimit for the maximum number of tables that a partitioned view canhold?If this is true, does anybody have any suggestions or ideas to workaround this max limit?TIA!
View 4 Replies
View Related
Aug 30, 2000
My client want me to update a table and the view with a new column which should be hidden. I am kind of confused on how to go about this in order to get a good result. PLEASE HELP!!
View 1 Replies
View Related
May 20, 2008
Hi
What permissions do I need to set so that a user can change tables, views and procedures?
View 7 Replies
View Related
Sep 15, 2015
I wonder how the query will be executed when querying to views.Is database engine will be extract the tables that are used to create the view and query for the result ?
View 5 Replies
View Related
Mar 17, 2008
If I have a view such as: SELECT T.* FROM T
When I add a column to table T the view is not updated to reflect that change.
Furthermore, if there are other columns after the * in the view (for example SELECT T.*, GETDATE() as "My Date" FROM T) the last columns will contain incorrect data.
Is there a work around for this? An "auto-recompile when tables are modified" kind of option?
Thanks
Nick
PS: This is the script I used for testing:
create table tt (
test1 int primary key,
test2 int)
go
insert into tt (test1, test2) values (1,2)
go
create view vw_tt as select *, getdate() as "My Date" from tt
go
select * from vw_tt
go
create view vw_tt2 as select * from tt
go
alter table tt add test3 int
go
select * from vw_tt
select * from vw_tt2
select * from tt
drop table tt
drop view vw_tt
drop view vw_tt2
View 9 Replies
View Related
Sep 25, 2006
Hi,
I have some simple views that bind to an Access forms for use in the detail side of Master/Detail forms.
The views are of the style:
SELECT *.OrderDetails, Products.TotalUnitsInStock AS UsefulReferenceInfo
FROM OrderDetails LEFT OUTER JOIN Products ON ..........
Using a database in SQL 2000, opening the view to directly insert values into the OrderDetails columns works perfectly, and Access correctly determines that there is an IDENTITY column that is the Primary Key. Insert works perfectly, form work perfectly.
Using the same SQL script to build a database in SQL 2005 the view doesn't detect that the column is an IDENTITY column so any attempt to insert data fails with the error "Invalid input parameter values. Check the status values for detail." Insert fails, form also doesn't work.
I have tested this in Access 2002, 2003 and 2007 B2TR and all give the same results so it seems to be a breaking change in SQL 2005.
It is easy to see when there is going to be trouble because the tell-tale '(Auto Number)' or more recently '(New)' text is missing from the appropriate identity column.
This is fairly inconvenient and breaks quite a lot of my Master/detail forms that use this design pattern.
Can anybody from the SQL team help shed some light on this for my.
Cheers Simon
View 11 Replies
View Related
Feb 1, 2007
I am building a dashboard features that allows user to select reports from a dropdownlist. It is pulling from a table called Reports (cols: ReportID, Description, sqlView) In this Report table the report is associated to a view that queries the report.
And the user's selections are stored in table called UserReport (cols: userID, ReportID, createDt) .
I need to get a Dataset to contain datables of all reports selected. (for example a user select 3 reports, the dataset should contain 3 datables that represent the report).
I want to accomplish this by create a store procedure that queries the Reports table and then dynamically executes the views that related to the user selected reports. Can anyone give me an example on how to create the storeprocedure?
Thanks,
CG
View 3 Replies
View Related
Jul 7, 2015
I have some Partitioned Views and on all queries using a table for the in clause, table elimination isn't happening.
Check Constraint is on the oid column
This works as expected, only goes to 2 tables;
SELECT *
FROM view_oap_all
WHERE oid IN ( '05231416529481', '06201479586431' )
This works as expected, only goes to 2 tables;
SELECT *
FROM view_oap_all
WHERE oid IN ( SELECT oid
FROM owners
WHERE oid IN ( '05231416529481', '06201479586431' ) )
This is checking all tables (headingnames are unique), ive tried this for the last 3 hours on many different tables containing the oid column.
Unless I write the oid as in the above queries it just doesn't work.
SELECT *
FROM view_oap_all
WHERE oid IN ( SELECT oid
FROM owners
WHERE headingname = 'TestSystem' )
View 6 Replies
View Related