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 2005 Forums
 Transact-SQL (2005)
 drop multiple views

Author  Topic 

fanfan2
Starting Member

5 Posts

Posted - 2010-11-24 : 11:56:51
Is there a way that I could drop multiple views with the same pre-fix all at once? Thanks.

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-24 : 11:58:25
probably with dynamic SQL

Got examples?

Make sure you have a backup or the code stored someplace first





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

fanfan2
Starting Member

5 Posts

Posted - 2010-11-24 : 12:14:55
where can I find examples?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-24 : 19:01:18
Do YOU have examples of the types of Names you want to drop

And why do you want to drop them

Got runaway code generating views...and creating tables on the fly as well?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-11-25 : 04:50:48
Jeeez brett...why not just post some example code? ->
SELECT 'drop view [' + table_name + ']'
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name LIKE 'myPrefix%'
AND TABLE_TYPE = 'view'


- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -