SlideShare a Scribd company logo
PRESENTS 
DNN Database Tips & Tricks
Will Strohl 
Director, Product Development 
@WillStrohl 
Author, founder of DNNCon, former ODUG President, 20+ OSS 
projects, former DNN Corp employee
@WillStrohl #QCDUG 
DNN Database Tips & Tricks 
WHY?
@WillStrohl #QCDUG 
DNN DATABASE TIPS & TRICKS 
• Can’t get to the UI 
• Troubleshoot development 
• Quick fix/edit 
• It’s the only way or faster 
• Repeatable scripts 
• Database information 
• Wipe out a database 
Why?
@WillStrohl #QCDUG 
AUTOMATE! 
HanselMinutes.com 
“If you have to do it more than 
once and it can be automated, 
automate it!”
@WillStrohl #QCDUG
SQL Server Management Studio DNN > Host > SQL 
@WillStrohl #QCDUG 
DNN SQL SCRIPTS 
SELECT * 
FROM [dbo].[Users] 
ORDER BY [CreatedOnDate] DESC; 
SELECT * 
FROM {databaseOwner}[{objectQualifier}Users] 
ORDER BY [CreatedOnDate] DESC;
CLEAR SPACE
@WillStrohl #QCDUG 
CLEAR SPACE 
Symptoms Problem 
• Tables have too much data 
• Page loads consistently slow 
• Event Viewer page won’t load 
• EventLog is too big 
• SiteLog is too big
@WillStrohl #QCDUG 
CLEAR SPACE 
DELETE FROM [dbo].[EventLog]; 
-- or 
TRUNCATE TABLE [dbo].[EventLog]; 
DELETE FROM [dbo].[SiteLog]; 
-- or 
TRUNCATE TABLE [dbo].[SiteLog];
@WillStrohl #QCDUG 
CLEAR SPACE 
Better… 
DELETE FROM [dbo].[EventLog] 
WHERE [LogCreateDate] <= DATEADD(day, -30, GETDATE()); 
DELETE FROM [dbo].[SiteLog] 
WHERE [DateTime] <= DATEADD(day, -30, GETDATE());
CHANGE DBO ROLE OWNER
@WillStrohl #QCDUG 
CHANGE DBO ROLE OWNER 
Symptoms Problem 
• [Create|Drop] failed for user 
‘<username>’. 
• User, group, or role 
‘<username>’ already exists in 
the current database. 
• The database principal owns a 
database role and cannot be 
dropped. 
• Your database already has a 
user of the same name 
• Common across development 
teams 
http://bit.ly/changednnroleowner
@WillStrohl #QCDUG 
CHANGE DBO ROLE OWNER 
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_FullAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_BasicAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_ReportingAccess] TO [dbo]; 
/* 
-- Necessary for Pre DNN 7.x 
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_FullAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_BasicAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_ReportingAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_FullAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_FullAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_BasicAccess] TO [dbo]; 
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_ReportingAccess] TO [dbo]; 
*/ 
DROP USER <your_username>;
CHANGE OR REPLACE THEMES
@WillStrohl #QCDUG 
CHANGE OR REPLACE THEMES 
Symptoms Problem 
• Have a rogue theme 
• Need to replace theme 
• Need to start fresh 
• No tool to reset theme 
• Resetting theme manually is 
too time consuming 
• Resetting the theme is 
dangerous 
http://bit.ly/cleardnnskins
@WillStrohl #QCDUG 
CHANGE OR REPLACE THEMES 
Find & Clear Default Site Settings 
-- find site settings for default theme settings 
SELECT [PortalID],[SettingName],[SettingValue] 
FROM [dbo].[PortalSettings] 
WHERE [SettingName] IN (N'DefaultAdminContainer', N'DefaultAdminSkin', 
N'DefaultPortalContainer', N'DefaultPortalSkin') 
AND [PortalID] = 0; 
-- update the site settings to remove the default theme settings 
UPDATE [dbo].[PortalSettings] 
SET [SettingValue] = NULL 
WHERE [SettingName] IN (N'DefaultAdminContainer', N'DefaultAdminSkin', 
N'DefaultPortalContainer', N'DefaultPortalSkin') 
AND [PortalID] = 0;
@WillStrohl #QCDUG 
CHANGE OR REPLACE THEMES 
Find & Clear Page Settings 
-- find pages with the skin set 
SELECT [TabID],[PortalID],[TabName],[SkinSrc],[ContainerSrc] 
FROM [dbo].[Tabs]; 
-- update all pages to remove skin settings 
UPDATE [dbo].[Tabs] 
SET [SkinSrc] = NULL, [ContainerSrc] = NULL 
WHERE [PortalID] = 0;
@WillStrohl #QCDUG 
CHANGE OR REPLACE THEMES 
Find & Clear Module Settings 
-- find modules with the container set 
SELECT [TabModuleID],[TabID],[ModuleID],[ContainerSrc] 
FROM [dbo].[TabModules]; 
-- update all modules to remove container settings 
UPDATE [dbo].[TabModules] 
SET [SkinSrc] = NULL, 
[ContainerSrc] = NULL 
WHERE [PortalID] = 0;
@WillStrohl #QCDUG 
CHANGE OR REPLACE THEMES 
Find & Replace Page Settings 
-- find pages with the skin set 
SELECT [TabID],[PortalID],[TabName],[SkinSrc],[ContainerSrc] 
FROM [dbo].[Tabs] 
WHERE [SkinSrc] LIKE N'%FutureGravity%' OR [ContainerSrc] LIKE N'%FutureGravity%'; 
-- update all pages to remove skin settings 
UPDATE [dbo].[Tabs] 
SET [SkinSrc] = REPLACE([SkinSrc], N'FutureGravity', N'Gravity'), 
[ContainerSrc] = REPLACE([ContainerSrc], N'FutureGravity', N'Gravity') 
WHERE [PortalID] = 0;
DATABASE OBJECT SIZES
@WillStrohl #QCDUG 
DATABASE OBJECT SIZES 
Symptoms Problem 
• Database fails 
• Disk space errors 
• Page load performance issues 
• Web host limits reached 
• The size of one or many 
database objects are too large 
http://bit.ly/dnndbsize
@WillStrohl #QCDUG 
DATABASE SIZE 
SELECT 
CASE TYPE 
WHEN 'U' 
THEN 'User Defined Tables' 
WHEN 'S' 
THEN 'System Tables' 
WHEN 'IT' 
THEN 'Internal Tables' 
WHEN 'P' 
THEN 'Stored Procedures' 
WHEN 'PC' 
THEN 'CLR Stored Procedures' 
WHEN 'X' 
THEN 'Extended Stored Procedures' 
END, 
COUNT(*) 
FROM SYS.OBJECTS 
WHERE TYPE IN ('U', 'P', 'PC', 'S', 'IT', 'X') 
GROUP BY TYPE 
SELECT 
database_name = DB_NAME(database_id) 
, log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) 
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) 
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) 
FROM sys.master_files WITH(NOWAIT) 
WHERE database_id = DB_ID() -- for current db 
GROUP BY database_id
@WillStrohl #QCDUG 
TABLE SIZE 
-- For storing values in the cursor 
DECLARE @TableName VARCHAR(100); 
-- Cursor to get the name of all user tables from the sysobjects listing 
DECLARE [tableCursor] CURSOR FOR 
SELECT [name] 
FROM [dbo].[sysobjects] 
WHERE OBJECTPROPERTY([id], N'IsUserTable') = 1 
FOR READ ONLY; 
-- A procedure level temp table to store the results 
CREATE TABLE #TempTable ( 
[tableName] VARCHAR(100), 
[numberofRows] VARCHAR(100), 
[reservedSize] VARCHAR(50), 
[dataSize] VARCHAR(50), 
[indexSize] VARCHAR(50), 
[unusedSize] VARCHAR(50) 
); 
-- Open the cursor 
OPEN [tableCursor]; 
-- Get the first table name from the cursor 
FETCH NEXT FROM [tableCursor] INTO @TableName; 
-- Loop until the cursor was not able to fetch 
WHILE (@@Fetch_Status >= 0) 
BEGIN 
-- Dump the results of the sp_spaceused query to the temp table
TAKE OVER A SITE LOCALLY
@WillStrohl #QCDUG 
TAKE OVER A SITE LOCALLY 
Symptoms Problem 
• Site inheritance issues 
• Need to create a login 
• Need to change user to host 
• Support has a time limit 
• Need to do this repeatedly 
• Production/local URL 
mismatch 
• Default URL setting gets in the 
way
@WillStrohl #QCDUG 
TAKE OVER A SITE LOCALLY 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
must be run before being able to see the site 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
DECLARE @NewAlias NVARCHAR(255), @PortalId INT; 
SET @NewAlias = N'somenewdomain.loc'; 
SET @PortalId = 0; 
-- change the old site URL to the new local one 
IF NOT EXISTS (SELECT 1 FROM [dbo].[PortalAlias] WHERE [HTTPAlias] = @NewAlias) 
BEGIN 
INSERT INTO [dbo].[PortalAlias] ([PortalID], [HTTPAlias], [CreatedByUserID], [CreatedOnDate], 
[LastModifiedByUserID], [LastModifiedOnDate], [IsPrimary]) 
VALUES (@PortalId, @NewAlias, -1, GETDATE(), -1, GETDATE(), 1); 
UPDATE [dbo].[PortalAlias] 
SET [IsPrimary] = 0 
WHERE NOT [HTTPAlias] = @NewAlias AND [PortalId] = @PortalId; 
END 
ELSE 
BEGIN 
UPDATE [dbo].[PortalAlias] 
SET [IsPrimary] = 1 
WHERE [HTTPAlias] = @NewAlias;
The passing of the buck… 
NEED MORE INFO?
@WillStrohl #QCDUG 
Paul Scarlett 
Adv. Systems Developer, HP Enterprise Services 
• Long time DNN enthusiast 
• SqlGridSelectedView 
• SQL expert 
• TressleWorks.ca 
• @PaulScarlett
Thank you! 
http://bit.ly/dnnsqlscripts 
@WillStrohl #QCDUG

More Related Content

What's hot (20)

PDF
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Brian Hay
 
PDF
Modern Front-End Development
mwrather
 
PDF
Upgrading to Drupal 8: Benefits and Gotchas
Suzanne Dergacheva
 
PPTX
Display Suite: A Themers Perspective
Mediacurrent
 
PDF
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Jonny Allbut
 
PDF
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
FortySeven Media
 
PDF
How Evoq Helps You Build Modern Web Applications
DNN
 
PPTX
Wordpress Shortcode
Binh Dang Ngoc
 
PDF
The Wonderful World of Drupal 8 Multilingual
Suzanne Dergacheva
 
PDF
Drupal 8, tricks and tips learned from the first 6 months
Iztok Smolic
 
PPTX
Untangling spring week4
Derek Jacoby
 
PDF
WordPress: After The Install
WordPress NYC
 
KEY
Features: A better way to package stuff in Drupal
Rob Knight
 
PPTX
Introduction to HTML5 & CSS3
g4gauravagarwal
 
PPTX
Responsive Layout Frameworks for XPages Application UI
Chris Toohey
 
PDF
WordPress development checklist
Binh Quan Duc
 
PPTX
Using Display Suite / Context to Build your Drupal Site
Matthew Wetmore
 
PDF
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
ODP
Using WordPress for Rapid Prototyping
Drew Morris
 
PDF
Drupal Presentation for CapitalCamp 2011: Features Driven Development
Mediacurrent
 
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Brian Hay
 
Modern Front-End Development
mwrather
 
Upgrading to Drupal 8: Benefits and Gotchas
Suzanne Dergacheva
 
Display Suite: A Themers Perspective
Mediacurrent
 
Build WordPress themes like a heavyweight - WordCamp Lancaster 2013
Jonny Allbut
 
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
FortySeven Media
 
How Evoq Helps You Build Modern Web Applications
DNN
 
Wordpress Shortcode
Binh Dang Ngoc
 
The Wonderful World of Drupal 8 Multilingual
Suzanne Dergacheva
 
Drupal 8, tricks and tips learned from the first 6 months
Iztok Smolic
 
Untangling spring week4
Derek Jacoby
 
WordPress: After The Install
WordPress NYC
 
Features: A better way to package stuff in Drupal
Rob Knight
 
Introduction to HTML5 & CSS3
g4gauravagarwal
 
Responsive Layout Frameworks for XPages Application UI
Chris Toohey
 
WordPress development checklist
Binh Quan Duc
 
Using Display Suite / Context to Build your Drupal Site
Matthew Wetmore
 
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
Using WordPress for Rapid Prototyping
Drew Morris
 
Drupal Presentation for CapitalCamp 2011: Features Driven Development
Mediacurrent
 

Viewers also liked (20)

PPTX
Kanban explained David Anderson LAS 2011-zurich
Walter Schärer
 
PDF
The Real-Time Web and its Future
ReadWrite
 
PDF
Real-Time Web: The future web in the enterprise
Teemu Arina
 
PPT
Preparación de exposiciones orales.
Susana
 
PDF
Cloud Company - Designing a Faster and More Intelligent Organization for the ...
Teemu Arina
 
PDF
Cloud Company: Social Technologies and Practices in Strategy, Management, and...
Teemu Arina
 
PPTX
DNN Connect 2014 - Enterprise Ecommerce and DotNetNuke
Thomas Stensitzki
 
PPT
DotNetNuke CMS: benefits for web professionals
I-business Solutions
 
PPTX
DotNetNuke: Be Like Bamboo
Will Strohl
 
PPT
Dot Net Nuke Presentation
Tony Cosentino
 
DOC
Lv phát triển các dịch vụ giá trị gia tăng (vas) của tập đoàn viễn thông quân...
Giang Coffee
 
PDF
Our Bodies, Disconnected: The Future Of Fitness APIs
ReadWrite
 
PDF
Vision of the future: Organization 2.0
Teemu Arina
 
PPTX
Networks, Networks Everywhere, And Not A Packet To Drink
ReadWrite
 
PDF
Upgrade Your Work Day With Quantified Self & Biohacking
Teemu Arina
 
PDF
Diccionario de brujas
gabychap
 
PDF
CATÁLOGO DE PIRATAS
SilvanaVeronica111
 
PDF
Web 2.0 Business Models
Teemu Arina
 
PPTX
Web Real-time Communications
Alexei Skachykhin
 
PDF
Brain Rules for Presenters
garr
 
Kanban explained David Anderson LAS 2011-zurich
Walter Schärer
 
The Real-Time Web and its Future
ReadWrite
 
Real-Time Web: The future web in the enterprise
Teemu Arina
 
Preparación de exposiciones orales.
Susana
 
Cloud Company - Designing a Faster and More Intelligent Organization for the ...
Teemu Arina
 
Cloud Company: Social Technologies and Practices in Strategy, Management, and...
Teemu Arina
 
DNN Connect 2014 - Enterprise Ecommerce and DotNetNuke
Thomas Stensitzki
 
DotNetNuke CMS: benefits for web professionals
I-business Solutions
 
DotNetNuke: Be Like Bamboo
Will Strohl
 
Dot Net Nuke Presentation
Tony Cosentino
 
Lv phát triển các dịch vụ giá trị gia tăng (vas) của tập đoàn viễn thông quân...
Giang Coffee
 
Our Bodies, Disconnected: The Future Of Fitness APIs
ReadWrite
 
Vision of the future: Organization 2.0
Teemu Arina
 
Networks, Networks Everywhere, And Not A Packet To Drink
ReadWrite
 
Upgrade Your Work Day With Quantified Self & Biohacking
Teemu Arina
 
Diccionario de brujas
gabychap
 
CATÁLOGO DE PIRATAS
SilvanaVeronica111
 
Web 2.0 Business Models
Teemu Arina
 
Web Real-time Communications
Alexei Skachykhin
 
Brain Rules for Presenters
garr
 
Ad

Similar to DNN Database Tips & Tricks (20)

PDF
Query Tuning for Database Pros & Developers
Code Mastery
 
PDF
SQL Server Dev ToolKit
Kirsten Benzel
 
PPTX
Ten query tuning techniques every SQL Server programmer should know
Kevin Kline
 
PDF
Back2 Basic Tools
sqlserver.co.il
 
PDF
Back 2 basics - SSMS Tips (IDf)
sqlserver.co.il
 
PDF
ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...
European Collaboration Summit
 
PPTX
Managing SQLserver for the reluctant DBA
Concentrated Technology
 
PPT
Mehta - SharePoint Data And Database Management
Nilesh Mehta
 
PPTX
1. SQL Server forSharePoint geeksA gentle introductionThomas Vochten • Septem...
BIWUG
 
PDF
The dr overnight dba
gdabate
 
PPTX
Databases 101
David Caughill
 
PPT
Managing SQLserver
Concentrated Technology
 
PPTX
Defy the Defaults
Mike Hillwig
 
PDF
SQL Database Performance Tuning for Developers
BRIJESH KUMAR
 
PDF
Optimizing SQL Server 2012 for SharePoint 2013
SharePoint Saturday New Jersey
 
PPTX
Pages tips and tricks
mccdonal
 
PPTX
Oracle Database Performance Tuning Basics
nitin anjankar
 
PPTX
Database 12c is ready for you... Are you ready for 12c?
Performance Tuning Corporation
 
PDF
Optimize sql server queries with these advanced tuning techniques tech repu
Kaing Menglieng
 
PDF
What's New in DBArtisan and Rapid SQL 2016
Embarcadero Technologies
 
Query Tuning for Database Pros & Developers
Code Mastery
 
SQL Server Dev ToolKit
Kirsten Benzel
 
Ten query tuning techniques every SQL Server programmer should know
Kevin Kline
 
Back2 Basic Tools
sqlserver.co.il
 
Back 2 basics - SSMS Tips (IDf)
sqlserver.co.il
 
ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...
European Collaboration Summit
 
Managing SQLserver for the reluctant DBA
Concentrated Technology
 
Mehta - SharePoint Data And Database Management
Nilesh Mehta
 
1. SQL Server forSharePoint geeksA gentle introductionThomas Vochten • Septem...
BIWUG
 
The dr overnight dba
gdabate
 
Databases 101
David Caughill
 
Managing SQLserver
Concentrated Technology
 
Defy the Defaults
Mike Hillwig
 
SQL Database Performance Tuning for Developers
BRIJESH KUMAR
 
Optimizing SQL Server 2012 for SharePoint 2013
SharePoint Saturday New Jersey
 
Pages tips and tricks
mccdonal
 
Oracle Database Performance Tuning Basics
nitin anjankar
 
Database 12c is ready for you... Are you ready for 12c?
Performance Tuning Corporation
 
Optimize sql server queries with these advanced tuning techniques tech repu
Kaing Menglieng
 
What's New in DBArtisan and Rapid SQL 2016
Embarcadero Technologies
 
Ad

More from Will Strohl (20)

PPTX
DNN Community Newsletter: An In-Person Review of Recent Open-Source Activity
Will Strohl
 
PPTX
Unveiling the Secrets of Software Company Transitions: Navigating the Path to...
Will Strohl
 
PPTX
DNN Awareness Group Presentation
Will Strohl
 
PPTX
DNN Summit 2021: DNN Upgrades Made Simple
Will Strohl
 
PPTX
DNN Summit: Robots.txt & Multi-Site DNN Instances
Will Strohl
 
PPTX
DNN CMS Awareness Group Meeting: December 2020
Will Strohl
 
PPTX
Tips & Tricks: Working from Home and Staying Productive
Will Strohl
 
PPTX
DNN Awareness Meeting July 2019
Will Strohl
 
PPTX
DNN-Connect 2019: DNN Horror Stories
Will Strohl
 
PPTX
DNN-Connect 2019: Build a Module in Minutes
Will Strohl
 
PPTX
DNN Awareness Meeting May 2019
Will Strohl
 
PPTX
DNN Awareness Meeting April 2019
Will Strohl
 
PPTX
DNN Awareness Meeting March 2019
Will Strohl
 
PPTX
DNN Awareness Meeting February 2019
Will Strohl
 
PPTX
DNN Awareness Meeting January 2019
Will Strohl
 
PPTX
DNN Awareness Meeting December 2018
Will Strohl
 
PPTX
DNN Upgrades Made Simple (DNN Summit 2019)
Will Strohl
 
PPTX
DNN Awareness EAG Meeting September 2018
Will Strohl
 
PPTX
DNN Awareness EAG Meeting August 2018
Will Strohl
 
PPTX
June 2018 DNN Awareness Group Meeting
Will Strohl
 
DNN Community Newsletter: An In-Person Review of Recent Open-Source Activity
Will Strohl
 
Unveiling the Secrets of Software Company Transitions: Navigating the Path to...
Will Strohl
 
DNN Awareness Group Presentation
Will Strohl
 
DNN Summit 2021: DNN Upgrades Made Simple
Will Strohl
 
DNN Summit: Robots.txt & Multi-Site DNN Instances
Will Strohl
 
DNN CMS Awareness Group Meeting: December 2020
Will Strohl
 
Tips & Tricks: Working from Home and Staying Productive
Will Strohl
 
DNN Awareness Meeting July 2019
Will Strohl
 
DNN-Connect 2019: DNN Horror Stories
Will Strohl
 
DNN-Connect 2019: Build a Module in Minutes
Will Strohl
 
DNN Awareness Meeting May 2019
Will Strohl
 
DNN Awareness Meeting April 2019
Will Strohl
 
DNN Awareness Meeting March 2019
Will Strohl
 
DNN Awareness Meeting February 2019
Will Strohl
 
DNN Awareness Meeting January 2019
Will Strohl
 
DNN Awareness Meeting December 2018
Will Strohl
 
DNN Upgrades Made Simple (DNN Summit 2019)
Will Strohl
 
DNN Awareness EAG Meeting September 2018
Will Strohl
 
DNN Awareness EAG Meeting August 2018
Will Strohl
 
June 2018 DNN Awareness Group Meeting
Will Strohl
 

Recently uploaded (20)

PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Digital Circuits, important subject in CS
contactparinay1
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

DNN Database Tips & Tricks

  • 1. PRESENTS DNN Database Tips & Tricks
  • 2. Will Strohl Director, Product Development @WillStrohl Author, founder of DNNCon, former ODUG President, 20+ OSS projects, former DNN Corp employee
  • 3. @WillStrohl #QCDUG DNN Database Tips & Tricks WHY?
  • 4. @WillStrohl #QCDUG DNN DATABASE TIPS & TRICKS • Can’t get to the UI • Troubleshoot development • Quick fix/edit • It’s the only way or faster • Repeatable scripts • Database information • Wipe out a database Why?
  • 5. @WillStrohl #QCDUG AUTOMATE! HanselMinutes.com “If you have to do it more than once and it can be automated, automate it!”
  • 7. SQL Server Management Studio DNN > Host > SQL @WillStrohl #QCDUG DNN SQL SCRIPTS SELECT * FROM [dbo].[Users] ORDER BY [CreatedOnDate] DESC; SELECT * FROM {databaseOwner}[{objectQualifier}Users] ORDER BY [CreatedOnDate] DESC;
  • 9. @WillStrohl #QCDUG CLEAR SPACE Symptoms Problem • Tables have too much data • Page loads consistently slow • Event Viewer page won’t load • EventLog is too big • SiteLog is too big
  • 10. @WillStrohl #QCDUG CLEAR SPACE DELETE FROM [dbo].[EventLog]; -- or TRUNCATE TABLE [dbo].[EventLog]; DELETE FROM [dbo].[SiteLog]; -- or TRUNCATE TABLE [dbo].[SiteLog];
  • 11. @WillStrohl #QCDUG CLEAR SPACE Better… DELETE FROM [dbo].[EventLog] WHERE [LogCreateDate] <= DATEADD(day, -30, GETDATE()); DELETE FROM [dbo].[SiteLog] WHERE [DateTime] <= DATEADD(day, -30, GETDATE());
  • 13. @WillStrohl #QCDUG CHANGE DBO ROLE OWNER Symptoms Problem • [Create|Drop] failed for user ‘<username>’. • User, group, or role ‘<username>’ already exists in the current database. • The database principal owns a database role and cannot be dropped. • Your database already has a user of the same name • Common across development teams http://bit.ly/changednnroleowner
  • 14. @WillStrohl #QCDUG CHANGE DBO ROLE OWNER ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_FullAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_BasicAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_ReportingAccess] TO [dbo]; /* -- Necessary for Pre DNN 7.x ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_FullAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_BasicAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_ReportingAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_FullAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_FullAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_BasicAccess] TO [dbo]; ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_ReportingAccess] TO [dbo]; */ DROP USER <your_username>;
  • 16. @WillStrohl #QCDUG CHANGE OR REPLACE THEMES Symptoms Problem • Have a rogue theme • Need to replace theme • Need to start fresh • No tool to reset theme • Resetting theme manually is too time consuming • Resetting the theme is dangerous http://bit.ly/cleardnnskins
  • 17. @WillStrohl #QCDUG CHANGE OR REPLACE THEMES Find & Clear Default Site Settings -- find site settings for default theme settings SELECT [PortalID],[SettingName],[SettingValue] FROM [dbo].[PortalSettings] WHERE [SettingName] IN (N'DefaultAdminContainer', N'DefaultAdminSkin', N'DefaultPortalContainer', N'DefaultPortalSkin') AND [PortalID] = 0; -- update the site settings to remove the default theme settings UPDATE [dbo].[PortalSettings] SET [SettingValue] = NULL WHERE [SettingName] IN (N'DefaultAdminContainer', N'DefaultAdminSkin', N'DefaultPortalContainer', N'DefaultPortalSkin') AND [PortalID] = 0;
  • 18. @WillStrohl #QCDUG CHANGE OR REPLACE THEMES Find & Clear Page Settings -- find pages with the skin set SELECT [TabID],[PortalID],[TabName],[SkinSrc],[ContainerSrc] FROM [dbo].[Tabs]; -- update all pages to remove skin settings UPDATE [dbo].[Tabs] SET [SkinSrc] = NULL, [ContainerSrc] = NULL WHERE [PortalID] = 0;
  • 19. @WillStrohl #QCDUG CHANGE OR REPLACE THEMES Find & Clear Module Settings -- find modules with the container set SELECT [TabModuleID],[TabID],[ModuleID],[ContainerSrc] FROM [dbo].[TabModules]; -- update all modules to remove container settings UPDATE [dbo].[TabModules] SET [SkinSrc] = NULL, [ContainerSrc] = NULL WHERE [PortalID] = 0;
  • 20. @WillStrohl #QCDUG CHANGE OR REPLACE THEMES Find & Replace Page Settings -- find pages with the skin set SELECT [TabID],[PortalID],[TabName],[SkinSrc],[ContainerSrc] FROM [dbo].[Tabs] WHERE [SkinSrc] LIKE N'%FutureGravity%' OR [ContainerSrc] LIKE N'%FutureGravity%'; -- update all pages to remove skin settings UPDATE [dbo].[Tabs] SET [SkinSrc] = REPLACE([SkinSrc], N'FutureGravity', N'Gravity'), [ContainerSrc] = REPLACE([ContainerSrc], N'FutureGravity', N'Gravity') WHERE [PortalID] = 0;
  • 22. @WillStrohl #QCDUG DATABASE OBJECT SIZES Symptoms Problem • Database fails • Disk space errors • Page load performance issues • Web host limits reached • The size of one or many database objects are too large http://bit.ly/dnndbsize
  • 23. @WillStrohl #QCDUG DATABASE SIZE SELECT CASE TYPE WHEN 'U' THEN 'User Defined Tables' WHEN 'S' THEN 'System Tables' WHEN 'IT' THEN 'Internal Tables' WHEN 'P' THEN 'Stored Procedures' WHEN 'PC' THEN 'CLR Stored Procedures' WHEN 'X' THEN 'Extended Stored Procedures' END, COUNT(*) FROM SYS.OBJECTS WHERE TYPE IN ('U', 'P', 'PC', 'S', 'IT', 'X') GROUP BY TYPE SELECT database_name = DB_NAME(database_id) , log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) , row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) , total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) FROM sys.master_files WITH(NOWAIT) WHERE database_id = DB_ID() -- for current db GROUP BY database_id
  • 24. @WillStrohl #QCDUG TABLE SIZE -- For storing values in the cursor DECLARE @TableName VARCHAR(100); -- Cursor to get the name of all user tables from the sysobjects listing DECLARE [tableCursor] CURSOR FOR SELECT [name] FROM [dbo].[sysobjects] WHERE OBJECTPROPERTY([id], N'IsUserTable') = 1 FOR READ ONLY; -- A procedure level temp table to store the results CREATE TABLE #TempTable ( [tableName] VARCHAR(100), [numberofRows] VARCHAR(100), [reservedSize] VARCHAR(50), [dataSize] VARCHAR(50), [indexSize] VARCHAR(50), [unusedSize] VARCHAR(50) ); -- Open the cursor OPEN [tableCursor]; -- Get the first table name from the cursor FETCH NEXT FROM [tableCursor] INTO @TableName; -- Loop until the cursor was not able to fetch WHILE (@@Fetch_Status >= 0) BEGIN -- Dump the results of the sp_spaceused query to the temp table
  • 25. TAKE OVER A SITE LOCALLY
  • 26. @WillStrohl #QCDUG TAKE OVER A SITE LOCALLY Symptoms Problem • Site inheritance issues • Need to create a login • Need to change user to host • Support has a time limit • Need to do this repeatedly • Production/local URL mismatch • Default URL setting gets in the way
  • 27. @WillStrohl #QCDUG TAKE OVER A SITE LOCALLY /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * must be run before being able to see the site * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ DECLARE @NewAlias NVARCHAR(255), @PortalId INT; SET @NewAlias = N'somenewdomain.loc'; SET @PortalId = 0; -- change the old site URL to the new local one IF NOT EXISTS (SELECT 1 FROM [dbo].[PortalAlias] WHERE [HTTPAlias] = @NewAlias) BEGIN INSERT INTO [dbo].[PortalAlias] ([PortalID], [HTTPAlias], [CreatedByUserID], [CreatedOnDate], [LastModifiedByUserID], [LastModifiedOnDate], [IsPrimary]) VALUES (@PortalId, @NewAlias, -1, GETDATE(), -1, GETDATE(), 1); UPDATE [dbo].[PortalAlias] SET [IsPrimary] = 0 WHERE NOT [HTTPAlias] = @NewAlias AND [PortalId] = @PortalId; END ELSE BEGIN UPDATE [dbo].[PortalAlias] SET [IsPrimary] = 1 WHERE [HTTPAlias] = @NewAlias;
  • 28. The passing of the buck… NEED MORE INFO?
  • 29. @WillStrohl #QCDUG Paul Scarlett Adv. Systems Developer, HP Enterprise Services • Long time DNN enthusiast • SqlGridSelectedView • SQL expert • TressleWorks.ca • @PaulScarlett

Editor's Notes

  • #11: DELETE is slower because it keeps logs and therefore can be rolled back without a TRANSACTION DELETE can use a WHERE clause TRUNCATE is faster because it doesn’t keep logs and therefore must be wrapped in a TRANSACTION in order to be rolled back TRUNCATE cannot use a WHERE clause