SlideShare a Scribd company logo
Tips & Tricks with SQL Server 
Performance Tuning, SSAS, SSRS, 
SSIS, and More! 
By Ike Ellis, MVP 
@ike_ellis 
www.ikeellis.com 
Blog.ikeellis.com 
http://www.linkedin.com/in/ikeellis
So you want to be great at SQL 
Server… SQL Server Integration Services 
SQL Server Analysis Services 
Tabular 
MultiDimensional 
SQL Server Reporting Services 
Excel 
Data Quality Services 
Service Broker 
Performance Tuning 
Indexing 
Query Plans 
Plan Analysis 
Memory Management 
SANs 
Network 
Clustering 
Availability Groups 
PowerShell 
Master Data Services 
Architecture 
Data Mart Design 
Data Normalization 
CDC 
NoSQL/BigData (At least the MS Cloud Offerings) 
Competitive Knowledge (Oracle, Tablaeu, QlickView, 
Postgres) 
ORMs(Entity Framework, Nhibernate, Micros) 
Installation/Configuration/Upgrading/Service Packing 
Power BI 
PowerMap 
PowerQuery 
PowerView 
PowerPivot 
T-SQL 
Querying 
Stored Procedures 
Functions 
Windowing Functions 
Aggregates 
CLR 
MDX 
DAX 
XMLA 
BCP 
SQL Azure 
Tooling 
Redgate 
SSMS 
SSDT 
Past Versions 
Central Management 
DacPacs/BacPacs 
Profiler/Extended Events 
Auditing 
Security/Encryption 
Replication 
SQLCMD
Tips From the SQL Consultant 
• For the YouTube/Reddit/Chive/Cracked/Meme generation 
• Lots of disjointed tips 
• Popular mistakes I see or easy things I think you can take 
advantage of 
• Between 3 – 5 minutes each 
• Let’s see if we can get through all 20
TIP #1: Query Shortcuts 
• SELECT COUNT(*) FROM 
• SELECT TOP 100 * FROM
TIP #2: Don’t forget the splitter 
bar
TIP #3: Low hanging fruit 
• CRTL-R 
– F6 switches between result tabs 
• Copy, Paste a line without selecting 
• COMMENTS CTRL-K, C, CTRL-K U 
• BOOKMARKS CTRL-K, K, CTRL-K N 
• Refresh cache – CTRL-SHIFT R 
– Unless RedGate then CTRL-SHIFT D
TIP #4: Block Commenting 
• Easy column selection – bring up the query window 
– CTRL-SHIFT Q 
• Format the columns comma first, like you’re supposed to 
– SQL PROMPT – CTRL-K, CTRL-Y 
• Alias a table 
• CTRL-ALT arrow 
• Add alias
TIP #5: Code Snippets 
• CTRL-K, CTRL-B – Bring up Code Snippet Manager 
• Copy an existing one from a path and put it in the My Snippets 
Path 
• Edit the XML 
• CTRL-K, CTRL-X to place the snippet 
• Great for common queries 
– WhoIsActive 
– sp_Blitz 
– DBCC OPENTRAN
Tip #6: SSIS for the Color Blind
Tip #7: Five minutes on report formatting = 10x more 
impressive 
• Spend 10 minutes on design (as opposed to the zero we 
typically spend) 
• Choose colors wisely 
– 99/100 - developers use the default color palette 
• HTML color picker websites 
– http://www.lavishbootstrap.com 
• MorgueFile 
– http://www.morguefile.com/
Tip #8: The right way to find hardware 
problems 
• Merging PerfMon and Tracing 
• Get the Batch and Completed Events Only 
• Never trace from the computer you are monitoring 
• Always trace to a file and then load in a table after. 
11 
*Thanks, Grant!
Tip #9: Lifehack: Readable Presentations 
• Take the average age of the 
people in your audience and 
divide by 2: That’s your font 
size 
• USE THIS SIZE IF YOUR 
AUDIENCE IS 110
Tip #10: Check for heaps/clustered 
indexes 
SELECT t.[Name] FROM sys.Indexes i 
JOIN sys.Tables t 
ON t.Object_ID = i.Object_id 
WHERE i.type_desc = 'HEAP' 
ORDER BY t.[Name]
Tip #11: The proper way to run an SSIS 
package
Tip #12: No reason to use ISNULL  
CONCAT! 
• Messy vs clean code 
• No + symbol needed 
• No ISNULL needed
Tip #13: How to search schema 
• F7 
• SQLSearch 
– Free 
– Download it! 
– http://www.red-gate.com/products/sql-development/sql-search/ 
– Did I mention it’s free? 
• Dependency Tracker 
– Not Free, but still cool 
select object_name(object_id), definition as name 
from sys.all_sql_modules 
where definition like '%cust%'
Tip #14: Windowing Functions are pretty 
cool 
• They are worth learning, and have a neat evolution
Tip #15: SSDT Search for options 
• No more digging around in options 
• Just search for everything
Tip #16: Scripting: You have two 
choices 
• Two Choices 
– Get good at boring repetitive tasks 
– Get good at PowerShell & Scripting 
• Who adds more value to their company or their customers? 
• Who gets paid more?
Tip #17: TempDB Configuration 
• Current thought is 4 logical processors to 1 file 
• Just a good beginning, your mileage may very 
• Start there, then go to 2:1 or 1:1 if necessary 
• Trace Flag 1117 or autogrow off
Tip #18: Prettify! 
21 
http://extras.sqlservercentral.com/prettifier/prettifier.aspx 
RedGate PlugIn for SQL Server Management Studio
Tip #19: Execute scripts over multiple 
servers? 
• Super easy!
Tip #20: Life is so easy with a dates 
table 
• Find the sales numbers for the first Monday of every month 
of the year 
• T-SQL with no dates table 
• T-SQL with dates table
Tip #21: Try_Cast 
• Avoiding terrible casting errors
Tip #22: Never reinvent the wheel 
• Take SQL# for example 
• Good Documentation 
• Easy Syntax 
• Cheap (and much of it is free)
Tip #23: Save scripts for easy 
access 
• Lots of repetitive scripts with business logic 
• No reason to write the same queries for the same tables 
day after day
Tip #24: Enforce Business Rules in the 
DB 
• Foreign Keys 
• Unique Constraints 
• Check Constraints 
27
Tip #25: Log, Log, Log (and beware of subscriptions) 
select c.Name 
, e.InstanceName 
, e.UserName 
, e.Parameters 
, e.TimeStart 
, e.TimeEnd 
, e.TimeDataRetrieval 
, e.TimeProcessing 
, e.TimeRendering 
from executionlog e 
join catalog c 
on e.reportid = c.ItemID 
Send a Link, or a file on a shared folder that you can audit. Find someway to audit 
who opened the link or the file in the folder. Try to avoid sending the PDF without 
a way to audit it.
Ike Ellis 
• http://blog.ikeellis.com 
• http://www.ikeellis.com 
• YouTube 
– http://www.youtube.com/user/IkeEllisData 
• SQL Pass Book Readers 
– http://bookreaders.sqlpass.org/ 
• San Diego Tech Immersion Group 
• Twitter: @ike_ellis 
• 619.922.9801 
• Email address is just my first name @ikeellis.com

More Related Content

What's hot

SQL vs NoSQL
SQL vs NoSQLSQL vs NoSQL
SQL vs NoSQL
Jacinto Limjap
 
Know thy cost (or where performance problems lurk)
Know thy cost (or where performance problems lurk)Know thy cost (or where performance problems lurk)
Know thy cost (or where performance problems lurk)
Oren Eini
 
iForum 2015: SQL vs. NoSQL
iForum 2015: SQL vs. NoSQLiForum 2015: SQL vs. NoSQL
iForum 2015: SQL vs. NoSQL
Денис Резник
 
RavenDB Presentation
RavenDB PresentationRavenDB Presentation
RavenDB PresentationMark Rodseth
 
U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)
Michael Rys
 
ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)
Michael Rys
 
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
IDERA Software
 
Document Databases & RavenDB
Document Databases & RavenDBDocument Databases & RavenDB
Document Databases & RavenDB
Brian Ritchie
 
MS DevDay - SQLServer 2014 for Developers
MS DevDay - SQLServer 2014 for DevelopersMS DevDay - SQLServer 2014 for Developers
MS DevDay - SQLServer 2014 for Developers
Денис Резник
 
Introduction to RavenDB
Introduction to RavenDBIntroduction to RavenDB
Introduction to RavenDB
Sasha Goldshtein
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick Josevski
Nick Josevski
 
SQL vs. NoSQL. It's always a hard choice.
SQL vs. NoSQL. It's always a hard choice.SQL vs. NoSQL. It's always a hard choice.
SQL vs. NoSQL. It's always a hard choice.
Denis Reznik
 
Azure CosmosDB
Azure CosmosDBAzure CosmosDB
Azure CosmosDB
Fernando Mejía
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
Neil Mackenzie
 
Introduction to azure document db
Introduction to azure document dbIntroduction to azure document db
Introduction to azure document db
Antonios Chatzipavlis
 
Azure SQL & SQL Server 2016 JSON
Azure SQL & SQL Server 2016 JSONAzure SQL & SQL Server 2016 JSON
Azure SQL & SQL Server 2016 JSON
Davide Mauri
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
Julie Lerman
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Kyle Banerjee
 
SQL & NoSQL
SQL & NoSQLSQL & NoSQL

What's hot (20)

SQL vs NoSQL
SQL vs NoSQLSQL vs NoSQL
SQL vs NoSQL
 
Know thy cost (or where performance problems lurk)
Know thy cost (or where performance problems lurk)Know thy cost (or where performance problems lurk)
Know thy cost (or where performance problems lurk)
 
iForum 2015: SQL vs. NoSQL
iForum 2015: SQL vs. NoSQLiForum 2015: SQL vs. NoSQL
iForum 2015: SQL vs. NoSQL
 
RavenDB Presentation
RavenDB PresentationRavenDB Presentation
RavenDB Presentation
 
U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)
 
Intro to RavenDB
Intro to RavenDBIntro to RavenDB
Intro to RavenDB
 
ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)
 
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERAGeek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
Geek Sync | Data Integrity Demystified - Deborah Melkin | IDERA
 
Document Databases & RavenDB
Document Databases & RavenDBDocument Databases & RavenDB
Document Databases & RavenDB
 
MS DevDay - SQLServer 2014 for Developers
MS DevDay - SQLServer 2014 for DevelopersMS DevDay - SQLServer 2014 for Developers
MS DevDay - SQLServer 2014 for Developers
 
Introduction to RavenDB
Introduction to RavenDBIntroduction to RavenDB
Introduction to RavenDB
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick Josevski
 
SQL vs. NoSQL. It's always a hard choice.
SQL vs. NoSQL. It's always a hard choice.SQL vs. NoSQL. It's always a hard choice.
SQL vs. NoSQL. It's always a hard choice.
 
Azure CosmosDB
Azure CosmosDBAzure CosmosDB
Azure CosmosDB
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
 
Introduction to azure document db
Introduction to azure document dbIntroduction to azure document db
Introduction to azure document db
 
Azure SQL & SQL Server 2016 JSON
Azure SQL & SQL Server 2016 JSONAzure SQL & SQL Server 2016 JSON
Azure SQL & SQL Server 2016 JSON
 
RavenDB Overview
RavenDB OverviewRavenDB Overview
RavenDB Overview
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
 
SQL & NoSQL
SQL & NoSQLSQL & NoSQL
SQL & NoSQL
 

Similar to Tips & Tricks SQL in the City Seattle 2014

SQL Server Tips & Tricks
SQL Server Tips & TricksSQL Server Tips & Tricks
SQL Server Tips & Tricks
Ike Ellis
 
SQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & TricksSQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & Tricks
Ike Ellis
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should know
Kevin Kline
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for Developers
Michael Rys
 
Quick & Easy SQL Tips
Quick & Easy SQL TipsQuick & Easy SQL Tips
Quick & Easy SQL Tips
Ike Ellis
 
Quick & Easy SQL Tips
Quick & Easy SQL TipsQuick & Easy SQL Tips
Quick & Easy SQL Tips
Ike Ellis
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
David Keener
 
SQL Server Worst Practices - EN
SQL Server Worst Practices - ENSQL Server Worst Practices - EN
SQL Server Worst Practices - EN
Gianluca Sartori
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New Features
Embarcadero Technologies
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
ColdFusionConference
 
Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best Practices
Vivek Chawla
 
Designing, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons LearnedDesigning, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons Learned
Denny Lee
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
Zohar Elkayam
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
IDERA Software
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
Harry Zheng
 
Boosting the Performance of your Rails Apps
Boosting the Performance of your Rails AppsBoosting the Performance of your Rails Apps
Boosting the Performance of your Rails Apps
Matt Kuklinski
 
ow.ppt
ow.pptow.ppt
ow.ppt
ssuser96a63c
 
ow.ppt
ow.pptow.ppt
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
Łukasz Grala
 

Similar to Tips & Tricks SQL in the City Seattle 2014 (20)

SQL Server Tips & Tricks
SQL Server Tips & TricksSQL Server Tips & Tricks
SQL Server Tips & Tricks
 
SQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & TricksSQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & Tricks
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should know
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for Developers
 
Quick & Easy SQL Tips
Quick & Easy SQL TipsQuick & Easy SQL Tips
Quick & Easy SQL Tips
 
Quick & Easy SQL Tips
Quick & Easy SQL TipsQuick & Easy SQL Tips
Quick & Easy SQL Tips
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
 
SQL Server Worst Practices - EN
SQL Server Worst Practices - ENSQL Server Worst Practices - EN
SQL Server Worst Practices - EN
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New Features
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best Practices
 
Designing, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons LearnedDesigning, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons Learned
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
Boosting the Performance of your Rails Apps
Boosting the Performance of your Rails AppsBoosting the Performance of your Rails Apps
Boosting the Performance of your Rails Apps
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
Ow
OwOw
Ow
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
 

More from Ike Ellis

Storytelling with Data with Power BI
Storytelling with Data with Power BIStorytelling with Data with Power BI
Storytelling with Data with Power BI
Ike Ellis
 
Storytelling with Data with Power BI.pptx
Storytelling with Data with Power BI.pptxStorytelling with Data with Power BI.pptx
Storytelling with Data with Power BI.pptx
Ike Ellis
 
Build a modern data platform.pptx
Build a modern data platform.pptxBuild a modern data platform.pptx
Build a modern data platform.pptx
Ike Ellis
 
Data Modeling on Azure for Analytics
Data Modeling on Azure for AnalyticsData Modeling on Azure for Analytics
Data Modeling on Azure for Analytics
Ike Ellis
 
Migrate a successful transactional database to azure
Migrate a successful transactional database to azureMigrate a successful transactional database to azure
Migrate a successful transactional database to azure
Ike Ellis
 
Data modeling trends for analytics
Data modeling trends for analyticsData modeling trends for analytics
Data modeling trends for analytics
Ike Ellis
 
Data modeling trends for Analytics
Data modeling trends for AnalyticsData modeling trends for Analytics
Data modeling trends for Analytics
Ike Ellis
 
Relational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsRelational data modeling trends for transactional applications
Relational data modeling trends for transactional applications
Ike Ellis
 
Power bi premium
Power bi premiumPower bi premium
Power bi premium
Ike Ellis
 
Move a successful onpremise oltp application to the cloud
Move a successful onpremise oltp application to the cloudMove a successful onpremise oltp application to the cloud
Move a successful onpremise oltp application to the cloud
Ike Ellis
 
Azure Databricks is Easier Than You Think
Azure Databricks is Easier Than You ThinkAzure Databricks is Easier Than You Think
Azure Databricks is Easier Than You Think
Ike Ellis
 
Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to dax
Ike Ellis
 
Pass the Power BI Exam
Pass the Power BI ExamPass the Power BI Exam
Pass the Power BI Exam
Ike Ellis
 
Slides for PUG 2018 - DAX CALCULATE
Slides for PUG 2018 - DAX CALCULATESlides for PUG 2018 - DAX CALCULATE
Slides for PUG 2018 - DAX CALCULATE
Ike Ellis
 
Introduction to DAX
Introduction to DAXIntroduction to DAX
Introduction to DAX
Ike Ellis
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
Ike Ellis
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
Ike Ellis
 
Dive Into Azure Data Lake - PASS 2017
Dive Into Azure Data Lake - PASS 2017Dive Into Azure Data Lake - PASS 2017
Dive Into Azure Data Lake - PASS 2017
Ike Ellis
 
11 Goals of High Functioning SQL Developers
11 Goals of High Functioning SQL Developers11 Goals of High Functioning SQL Developers
11 Goals of High Functioning SQL Developers
Ike Ellis
 
Hadoop for the Absolute Beginner
Hadoop for the Absolute BeginnerHadoop for the Absolute Beginner
Hadoop for the Absolute Beginner
Ike Ellis
 

More from Ike Ellis (20)

Storytelling with Data with Power BI
Storytelling with Data with Power BIStorytelling with Data with Power BI
Storytelling with Data with Power BI
 
Storytelling with Data with Power BI.pptx
Storytelling with Data with Power BI.pptxStorytelling with Data with Power BI.pptx
Storytelling with Data with Power BI.pptx
 
Build a modern data platform.pptx
Build a modern data platform.pptxBuild a modern data platform.pptx
Build a modern data platform.pptx
 
Data Modeling on Azure for Analytics
Data Modeling on Azure for AnalyticsData Modeling on Azure for Analytics
Data Modeling on Azure for Analytics
 
Migrate a successful transactional database to azure
Migrate a successful transactional database to azureMigrate a successful transactional database to azure
Migrate a successful transactional database to azure
 
Data modeling trends for analytics
Data modeling trends for analyticsData modeling trends for analytics
Data modeling trends for analytics
 
Data modeling trends for Analytics
Data modeling trends for AnalyticsData modeling trends for Analytics
Data modeling trends for Analytics
 
Relational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsRelational data modeling trends for transactional applications
Relational data modeling trends for transactional applications
 
Power bi premium
Power bi premiumPower bi premium
Power bi premium
 
Move a successful onpremise oltp application to the cloud
Move a successful onpremise oltp application to the cloudMove a successful onpremise oltp application to the cloud
Move a successful onpremise oltp application to the cloud
 
Azure Databricks is Easier Than You Think
Azure Databricks is Easier Than You ThinkAzure Databricks is Easier Than You Think
Azure Databricks is Easier Than You Think
 
Pass 2018 introduction to dax
Pass 2018 introduction to daxPass 2018 introduction to dax
Pass 2018 introduction to dax
 
Pass the Power BI Exam
Pass the Power BI ExamPass the Power BI Exam
Pass the Power BI Exam
 
Slides for PUG 2018 - DAX CALCULATE
Slides for PUG 2018 - DAX CALCULATESlides for PUG 2018 - DAX CALCULATE
Slides for PUG 2018 - DAX CALCULATE
 
Introduction to DAX
Introduction to DAXIntroduction to DAX
Introduction to DAX
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
Dive Into Azure Data Lake - PASS 2017
Dive Into Azure Data Lake - PASS 2017Dive Into Azure Data Lake - PASS 2017
Dive Into Azure Data Lake - PASS 2017
 
11 Goals of High Functioning SQL Developers
11 Goals of High Functioning SQL Developers11 Goals of High Functioning SQL Developers
11 Goals of High Functioning SQL Developers
 
Hadoop for the Absolute Beginner
Hadoop for the Absolute BeginnerHadoop for the Absolute Beginner
Hadoop for the Absolute Beginner
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 

Tips & Tricks SQL in the City Seattle 2014

  • 1. Tips & Tricks with SQL Server Performance Tuning, SSAS, SSRS, SSIS, and More! By Ike Ellis, MVP @ike_ellis www.ikeellis.com Blog.ikeellis.com http://www.linkedin.com/in/ikeellis
  • 2. So you want to be great at SQL Server… SQL Server Integration Services SQL Server Analysis Services Tabular MultiDimensional SQL Server Reporting Services Excel Data Quality Services Service Broker Performance Tuning Indexing Query Plans Plan Analysis Memory Management SANs Network Clustering Availability Groups PowerShell Master Data Services Architecture Data Mart Design Data Normalization CDC NoSQL/BigData (At least the MS Cloud Offerings) Competitive Knowledge (Oracle, Tablaeu, QlickView, Postgres) ORMs(Entity Framework, Nhibernate, Micros) Installation/Configuration/Upgrading/Service Packing Power BI PowerMap PowerQuery PowerView PowerPivot T-SQL Querying Stored Procedures Functions Windowing Functions Aggregates CLR MDX DAX XMLA BCP SQL Azure Tooling Redgate SSMS SSDT Past Versions Central Management DacPacs/BacPacs Profiler/Extended Events Auditing Security/Encryption Replication SQLCMD
  • 3. Tips From the SQL Consultant • For the YouTube/Reddit/Chive/Cracked/Meme generation • Lots of disjointed tips • Popular mistakes I see or easy things I think you can take advantage of • Between 3 – 5 minutes each • Let’s see if we can get through all 20
  • 4. TIP #1: Query Shortcuts • SELECT COUNT(*) FROM • SELECT TOP 100 * FROM
  • 5. TIP #2: Don’t forget the splitter bar
  • 6. TIP #3: Low hanging fruit • CRTL-R – F6 switches between result tabs • Copy, Paste a line without selecting • COMMENTS CTRL-K, C, CTRL-K U • BOOKMARKS CTRL-K, K, CTRL-K N • Refresh cache – CTRL-SHIFT R – Unless RedGate then CTRL-SHIFT D
  • 7. TIP #4: Block Commenting • Easy column selection – bring up the query window – CTRL-SHIFT Q • Format the columns comma first, like you’re supposed to – SQL PROMPT – CTRL-K, CTRL-Y • Alias a table • CTRL-ALT arrow • Add alias
  • 8. TIP #5: Code Snippets • CTRL-K, CTRL-B – Bring up Code Snippet Manager • Copy an existing one from a path and put it in the My Snippets Path • Edit the XML • CTRL-K, CTRL-X to place the snippet • Great for common queries – WhoIsActive – sp_Blitz – DBCC OPENTRAN
  • 9. Tip #6: SSIS for the Color Blind
  • 10. Tip #7: Five minutes on report formatting = 10x more impressive • Spend 10 minutes on design (as opposed to the zero we typically spend) • Choose colors wisely – 99/100 - developers use the default color palette • HTML color picker websites – http://www.lavishbootstrap.com • MorgueFile – http://www.morguefile.com/
  • 11. Tip #8: The right way to find hardware problems • Merging PerfMon and Tracing • Get the Batch and Completed Events Only • Never trace from the computer you are monitoring • Always trace to a file and then load in a table after. 11 *Thanks, Grant!
  • 12. Tip #9: Lifehack: Readable Presentations • Take the average age of the people in your audience and divide by 2: That’s your font size • USE THIS SIZE IF YOUR AUDIENCE IS 110
  • 13. Tip #10: Check for heaps/clustered indexes SELECT t.[Name] FROM sys.Indexes i JOIN sys.Tables t ON t.Object_ID = i.Object_id WHERE i.type_desc = 'HEAP' ORDER BY t.[Name]
  • 14. Tip #11: The proper way to run an SSIS package
  • 15. Tip #12: No reason to use ISNULL  CONCAT! • Messy vs clean code • No + symbol needed • No ISNULL needed
  • 16. Tip #13: How to search schema • F7 • SQLSearch – Free – Download it! – http://www.red-gate.com/products/sql-development/sql-search/ – Did I mention it’s free? • Dependency Tracker – Not Free, but still cool select object_name(object_id), definition as name from sys.all_sql_modules where definition like '%cust%'
  • 17. Tip #14: Windowing Functions are pretty cool • They are worth learning, and have a neat evolution
  • 18. Tip #15: SSDT Search for options • No more digging around in options • Just search for everything
  • 19. Tip #16: Scripting: You have two choices • Two Choices – Get good at boring repetitive tasks – Get good at PowerShell & Scripting • Who adds more value to their company or their customers? • Who gets paid more?
  • 20. Tip #17: TempDB Configuration • Current thought is 4 logical processors to 1 file • Just a good beginning, your mileage may very • Start there, then go to 2:1 or 1:1 if necessary • Trace Flag 1117 or autogrow off
  • 21. Tip #18: Prettify! 21 http://extras.sqlservercentral.com/prettifier/prettifier.aspx RedGate PlugIn for SQL Server Management Studio
  • 22. Tip #19: Execute scripts over multiple servers? • Super easy!
  • 23. Tip #20: Life is so easy with a dates table • Find the sales numbers for the first Monday of every month of the year • T-SQL with no dates table • T-SQL with dates table
  • 24. Tip #21: Try_Cast • Avoiding terrible casting errors
  • 25. Tip #22: Never reinvent the wheel • Take SQL# for example • Good Documentation • Easy Syntax • Cheap (and much of it is free)
  • 26. Tip #23: Save scripts for easy access • Lots of repetitive scripts with business logic • No reason to write the same queries for the same tables day after day
  • 27. Tip #24: Enforce Business Rules in the DB • Foreign Keys • Unique Constraints • Check Constraints 27
  • 28. Tip #25: Log, Log, Log (and beware of subscriptions) select c.Name , e.InstanceName , e.UserName , e.Parameters , e.TimeStart , e.TimeEnd , e.TimeDataRetrieval , e.TimeProcessing , e.TimeRendering from executionlog e join catalog c on e.reportid = c.ItemID Send a Link, or a file on a shared folder that you can audit. Find someway to audit who opened the link or the file in the folder. Try to avoid sending the PDF without a way to audit it.
  • 29. Ike Ellis • http://blog.ikeellis.com • http://www.ikeellis.com • YouTube – http://www.youtube.com/user/IkeEllisData • SQL Pass Book Readers – http://bookreaders.sqlpass.org/ • San Diego Tech Immersion Group • Twitter: @ike_ellis • 619.922.9801 • Email address is just my first name @ikeellis.com

Editor's Notes

  1. use tsql2012 SELECT * FROMSales.customers go select * from sales.orders go select top 100000 * from sales.orders, sales.customers
  2. update sales.customers set contacttitle = null where custid in ('59', '66', '78', '15') use tsql2012 select * from sales.customers select ContactName + ' - ' + ContactTitle + ', ' + City as GreetingLine from sales.customers select isnull(ContactName, '') + ' - ' + isnull(ContactTitle, '') + ', ' + isnull(City, '') as GreetingLine from sales.customers select concat(ContactName, ' ', ContactTitle, ' ', City) as GreetingLine from sales.customers
  3. use tsql2012 select * from sales.orders select custid, freight from sales.orders select custid, freight, sum(freight) as totalFreight from sales.orders select custid, sum(freight) as totalFreight from sales.orders group by custid select custid, freight, sum(freight) as totalFreight from sales.orders group by custid select custid, freight, sum(freight) as totalFreight from sales.orders group by custid, freight --we're skipping subqueries, because they look ugly and --it insults me aesthetically ;with FreightTotal as ( select custid, sum(freight) as totalFreight from sales.orders group by custid ) select o.custid , o.freight , ft.totalFreight as totalFreight from sales.orders o join FreightTotal ft on o.custid = ft.custid --BIG IMPROVEMENT --query can be executed independantly --Can be reused, like this ;with FreightTotal as ( select custid, sum(freight) as totalFreight from sales.orders group by custid ) select o.custid , o.freight , ft.totalFreight as totalFreight , o.freight /ft.totalfreight * 100 as FreightPercentage from sales.orders o join FreightTotal ft on o.custid = ft.custid --but remember our original thought process select custid, freight, sum(freight) as totalFreight from sales.orders --here's a windowing function select custid , freight , sum(freight) over (partition by custid) as totalFreight from sales.orders --and reusing it is not that big of a deal select custid , freight , sum(freight) over (partition by custid) as totalFreight , freight / sum(freight) over (partition by custid) * 100 as FreightPercentage from sales.orders
  4. # We can narrow down the list by filtering on the source Get-EventLog Application | Where-Object {$_.Source -like '*sql*' ` -and $_.EntryType -eq "Error" ` -and $_.TimeGenerated -ge ((Get-Date).AddHours(-96)) ` } | Format-List Write-Host "Press any key to continue ..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host Write-Host "A" Write-Host "B" Write-Host "C"
  5. SELECT * FROM (SELECT urgency, name, phone, location, department, cc, status, case_manager, ip, case_manager_ei d, id_problem, id_problem_type, eid_author, title, body, date_created, date_modified FROM problems AS main INNER JOIN (SELECT id_problem as t_urgency_id_problem, node_value AS urgency FROM problem_nodes WHERE node_name = "urgency")t_urgency ON t_urgency.t_urgency_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_name_id_problem, node_value AS name FROM problem_nodes WHERE node_name = "name")t_name ON t_name.t_name_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_phone_id_problem, node_value AS phone FROM problem_nodes WHERE node_name = "phone")t_phone ON t_phone.t_phone_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_location_id_problem, node_value AS location FROM problem_nodes WHERE node_name = "location")t_location ON t_location.t_location_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_department_id_problem, node_value AS department FROM problem_nodes WHERE node_name = "department")t_department ON t_department.t_department_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_cc_id_problem, node_value AS cc FROM problem_nodes WHERE node_name = "cc")t_cc ON t_cc.t_cc_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_status_id_problem, node_value AS status FROM problem_nodes WHERE node_name = "status")t_status ON t_status.t_status_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_case_manager_id_problem, node_value AS case_manager FROM problem_nodes WHERE node_name = "case_manager")t_case_manager ON t_case_manager.t_case_manager_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_ip_id_problem, node_value AS ip FROM problem_nodes WHERE node_name = "ip")t_ip ON t_ip.t_ip_id_problem = main.id_problem INNER JOIN (SELECT id_problem as t_case_manager_eid_id_problem, node_value AS case_manager_eid FROM problem_nodes WHERE node_name = "case_manager_eid") t_case_manager_eid ON t_case_manager_eid.t_case_manager_eid_id_problem = main.id_problem)t
  6. ;with FirstMondays as ( Select DateAdd(day, (9-DatePart(weekday, DateAdd(Month, 1+DateDiff(Month, 0, '12/1/2009'), 0)))%7, DateAdd(Month, 1+DateDiff(Month, 0, '12/1/2009'), 0)) as FirstMonday union all select DateAdd(day, (9-DatePart(weekday, DateAdd(Month, 1+DateDiff(Month, 0, FirstMonday), 0)))%7, DateAdd(Month, 1+DateDiff(Month, 0, FirstMonday), 0)) from FirstMondays where firstMonday <= '12/1/2010' ) select * from FirstMondays use adventureworksdw2012 select EnglishMonthName, min(datekey) from dimdate where englishdaynameofweek = 'monday' and calendaryear = '2010' group by EnglishMonthName, MonthNumberOfYear order by MonthNumberOfYear
  7. create table t1 (col1 varchar(100)) insert into t1 (col1) values ('1') ,('2') ,('3') ,('ike') ,('1') ,('2') ,('3') ,('ike') , ('1') ,('2') ,('3') ,('ike') select cast(col1 as int) from t1 select try_cast(col1 as int) from t1
  8. SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'D', '') -- Thursday, December 03, 2009 SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'D', 'de') SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'D', 'fr-fr') -- jeudi 3 décembre 2009 SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'dd', '') -- 03 SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'dd-MMM', '') SELECT SQL#.Date_Format('2009-12-03 12:45:56.345', 'tt', 'ja-jp') -- 午後 SELECT SQL#.Math_IsPrime(12318237133333)
  9. Watch the actual execution plan for these statements: drop table dbo.t1 drop table dbo.t2 --create two test tables create table dbo.t1 (c1 int , c2 int check(c2 between 10 and 20)); insert into dbo.t1 values (11,12); create table dbo.t2 (c1 int , c2 int); go insert into dbo.t2 values (101, 102); go select t1.c1 , t2.c2 , t2.c2 from dbo.t1 join dbo.t2 on t1.c1 = t2.c2 and t1.c2 = 20; select t1.c1 , t1.c2 , t2.c2 from dbo.t1 join dbo.t2 on t1.c1 = t2.c2 and t1.c2 = 30;
  10. DBCC OPENTRAN select s.plan_handle , t.text , sum(s.execution_count) as totalExecutionCount , sum(s.total_elapsed_time) as totalElapsedTime , sum(s.total_worker_time) as totalWorkerTime , sum(s.total_logical_reads) as totalLogicalReads , sum(s.total_logical_writes) as totalLogicalWrites from sys.dm_exec_query_stats s cross apply sys.dm_exec_sql_text(s.plan_handle) t group by s.plan_handle, t.text order by sum(s.execution_count) desc