Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Changing vieew definiton

Author  Topic 

amsqlguy
Yak Posting Veteran

89 Posts

Posted - 2010-10-11 : 14:12:45
Guys

I have two columns in a table (organization) as orgname and type which are getting moved to organization_detail. The organization table is referenced in 200 views for these two columns is there a generic way to change the view definitions to point to the new table for these two columns organization_detail

Please refer to below example for sample

OLD DEFINITION

select e.id, e.name, o.orgname, o.orgtype, o.estyear, o.location
from employee e inner join organization o
on e.id = o.empid

NEW DEFINITION

select e.id, e.name, od.orgname, od.orgtype, o.estyear, o.location
from employee e inner join organization o on e.id = o.empid
inner join organization_detail od on od.orgid = o.id

Any suggestions/inputs would help.

Thanks

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-10-11 : 14:46:41
might be easiest to make a view with the exact name and column names of the original table. that way all the views will just work without modifying them all
Go to Top of Page

amsqlguy
Yak Posting Veteran

89 Posts

Posted - 2010-10-11 : 14:50:29
The columns will be named the exact, but how would you ensure that a new join gets added and table reference in the select list for the columns changes in all 200 views.

Thanks
Go to Top of Page
   

- Advertisement -