sql - sybase: how do I drop all tables, and stored procs if possible? -


i want drop tables , stored procedures in schema, know how this? i'd avoid dropping entire database if possible.

you iterate on sysobjects table series of drops , systematically drop objects want gone.

declare tables cursor  select name sysobjects type='u' go declare @name varchar(255) open tables fetch tables @name while (@@sqlstatus = 0) begin exec("drop table "+ @name) fetch tables @name end close tables deallocate cursor tables 

yes requires cursors , it's gonna bit slow should pretty wipe database clean.

  • for tables need have type='u' , use drop table in loop
  • for stored procesures have p or xp , use drop procedure in loop

more information:


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -