Clean out the tables from a DotNetNuke Database
Sep
8
Written by:
Wednesday, September 08, 2010 2:37 PM
Every now and again I get a failed DNN installation with a half-created database. When that happens, the best course of action is to clean out the database and start again with the install, making sure the problem is fixed. But how do you clean out the database?
Here’s a quick script I wrote to do this – to be run through a Sql query tool.
Note : don’t ever run this unless you want to actually destroy your DotNetNuke database. It’s a scorched earth deletion. It’s the Sql equivalent of delete *.* in old DOS days – except Sql Server won’t give you an ‘Are you sure?’ prompt.
Here’s the script:
declare @tableName nvarchar(100), @sql nvarchar(255)
declare drop_curs cursor for
select Name from sysobjects
where type = 'u'
and (name like 'dnn_%' or name like ‘aspnet_%’)
open drop_curs
fetch from drop_curs into @tablename
while @@fetch_status = 0
begin
select @sql = 'drop table ' + @tablename
execute (@sql)
fetch from drop_curs into @tablename
end
close drop_curs
deallocate drop_curs
2 comment(s) so far...
Re: Clean out the tables from a DotNetNuke Database
Great script!
But why "... name like 'dnn_%' ...". Do not think all uses "dnn" as qualifier.
You should add qualifier as param to this query, because at the one DB can be more then one DNN installations ;)
By Sergey on
Thursday, September 09, 2010 3:09 AM
|
Re: Clean out the tables from a DotNetNuke Database
@sergey : yes, you're right. If you don't use the dnn_ prefix, you'll have to figure out another way.
I *always* suggest using the prefix. It's good database management to use table prefixes to define systems and subsystems.
By Bruce Chapman on
Thursday, September 09, 2010 10:07 AM
|