March 5, 2007 at 10:37 am
Currently I have a nightly process that does a datapull from a 3rd party Sql Server database into our datawarehouse. The users need the data in the warehouse to be updated more then nightly.
The plan is to create two tables (userInformation1, userInformation2 )and two views ( vUserInformation, vUserInformationLoad). This is to allow the database to pull the data into vUserInformatinoLoad and then at the end of the pull have the last step execute some ddl scripts on the views.
drop view vUserInformation
drop view vUserInformationLoad
create view vUserInformation as select * from userInformation1
create view vUserInformationLoad as select * from userInformation2
This would allow the current data to be available to the user and then when a load is ran at the end the warehouse has the latest greatest with very little down time.
QUESTION: How to programmatically determine the source for the view? (which table is the view currently point at?)
Note: searching for 'view' information is so fun. Everything view this view that.
thanks
Daryl
March 5, 2007 at 12:05 pm
I might be mis-understanding the question, but...
if you are re-using the same view name, and recreating it with different SELECT statements, then you should be able to use the command EXEC sp_depends VIEWNAME;
that will list all tables and columns referenced in the view: here's some sample output:
name | type | updated | selected | column |
dbo.TBSUBOUT | user table | no | no | DESCRIP |
dbo.TBGMSTAT | user table | no | no | STATUSTBLKEY |
dbo.TBGMSTAT | user table | no | no | DESCRIP |
dbo.GMOUTCOM | user table | no | no | SUBOUTTBLKEY |
dbo.GMOUTRSL | user table | no | no | RESULTTBLKEY |
dbo.TBSUBOUT | user table | no | no | SUBOUTTBLKEY |
dbo.GMACTOUT | user table | no | no | RESULTTBLKEY |
dbo.GMOUTCOM | user table | no | no | ACTTYOUTTBLKEY |
dbo.GMOUTCOM | user table | no | no | OUTCOMETBLKEY |
dbo.GMACTOUT | user table | no | no | ACTUAL |
dbo.GMACTOUT | user table | no | no | STATUSTBLKEY |
dbo.GMACTOUT | user table | no | no | OUTCOMEDT |
dbo.GMACTOUT | user table | no | no | ACTTBLKEY |
dbo.GMACTOUT | user table | no | no | ACTTYOUTTBLKEY |
dbo.GMACTOUT | user table | no | no | PROPOSED |
dbo.GMACT | user table | no | no | ACTNBR |
dbo.GMACT | user table | no | no | ACTNAME |
dbo.GMACT | user table | no | no | IDISACTNBR |
dbo.TBOUTCOM | user table | no | no | OUTCOMETBLKEY |
dbo.TBOUTCOM | user table | no | no | DESCRIP |
dbo.GMACT | user table | no | no | ACTTBLKEY |
if you want the View's definition, then exec sp_helptext VIEWNAME would give you the raw source?
Lowell
March 5, 2007 at 9:23 pm
Either the sp_helptext or sp_depends will do grand!
I will be creating a temp (or variable table) and checking the results to determine which way to switch the data and load views.
thanks
Daryl
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply