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 2000 Forums
 Transact-SQL (2000)
 Change all table in all view

Author  Topic 

chalana2004
Starting Member

3 Posts

Posted - 2006-01-10 : 07:58:08
hi all ,
i have 60 VIEWS (SQLSERVER) with the table dbo.tblname and i want to replace the table dbo.tblname with the table dbo.tblname in all VIEWS with xdb.tblname .how can i do it automatically with a store procedure or a script ?
thanks

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-10 : 08:57:20
Generate scripts, Use Find & replace
Run the script
Go to Top of Page

chalana2004
Starting Member

3 Posts

Posted - 2006-01-12 : 04:54:40
quote:
Originally posted by Srinika

Generate scripts, Use Find & replace
Run the script


please how can i generate a script?
thanks bye
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-12 : 04:56:48
use Enterprise Manager, navigate to VIEWS, select the views that you want, right click and select GENERATE SQL SCRIPT

-----------------
'KH'

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Go to Top of Page

chalana2004
Starting Member

3 Posts

Posted - 2006-01-12 : 05:00:44
thanks but my question ist how can i do it automatically for all 60 views?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-12 : 05:23:28
Do as Srinika suggested, is it good enough ?

-----------------
'KH'

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-01-12 : 14:30:40
"thanks but my question ist how can i do it automatically for all 60 views?"

It will take about 5 minutes, probably less, using the suggestions method. Is this good enough, or do you have a recurring need which makes it necessary to "automate" this?

Kristen
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-12 : 19:42:53
>> do it automatically
How often you are going to do this ? This should be a one off task. If you have to keep changing your view's base table there might be something wrong in the design.

-----------------
'KH'

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Go to Top of Page
   

- Advertisement -