Shawn Weisfeld

I find when I talk to myself nobody listens. - Shawn Weisfeld
posts - 356, comments - 173, trackbacks - 34

My Links

News

The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.

Archives

Post Categories

Drop Me!

I was trying to get rid of all the objects (tables, procedures, views) in my database and whipped up this little script and while it is far from perfect it is well worth sharing. . .

SELECT
 CASE WHEN type = 'P' THEN 'DROP PROCEDURE ' + name
      WHEN type = 'U' THEN 'DROP TABLE ' + name
   WHEN type = 'V' THEN 'DROP VIEW ' + name
      WHEN type = 'FN' THEN 'DROP FUNCTION ' + name
    ELSE '' END AS dropSQL, *
FROM sys.objects
WHERE type != 'S' AND type != 'IT' AND type != 'SQ'

Print | posted on Saturday, April 12, 2008 10:03 PM | Filed Under [ SQL ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 7 and 8 and type the answer here:

Powered by: