select - How to clear all tables selected through a INFORMATION_SCHEMA.TABLES query in SQL? -


this question has answer here:

the result list of few hundred tables have useless rows should cleared. how can without manually typing each one?

not trying delete all tables, ones been selected through ,

declare @sql_string nvarchar(max) declare @tablename  nvarchar(max)  declare db_cursor cursor     -- might want modify in order      -- specific subset of tables     select table_name      information_schema.tables open db_cursor     fetch next db_cursor  @tablename  while @@fetch_status = 0 begin       set @sql_string = n'delete * ' + quotename(@tablename)     exec sp_executesql @sql_string      fetch next db_cursor      @tablename         end     close db_cursor    deallocate db_cursor 

something should trick.

as always, when deleting records in tables without where clause, careful.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -