SlideShare a Scribd company logo
1 of 3
Download to read offline
T-SQLCoding Conventions, Best Practices, Tips and Programming Guidelines
BY-VISHAL PAWAR
T - SQL
Do not use SELECT *
Use parametrized
queries
Create Clustered and
Non-Clustered Indexes
For enumerated value
create look up Table
Think SQL injection
SP-Stores Procedure
Comment well
Singular Name for table Avoid side cursors Test - Large databases Keep clustered index
small
Store image paths or
URLs
Think usage of functions
in WHERE clauses
SP-Faster than CRUD
Consistent Names Use SET NOCOUNT ON Timeouts Awareness Avoid Cursors Use LIKE clause properly Use set-based solutions SP-Easy Maintenance
Don’t use space for
names
Un normalized – Not
Broken Business Entity
a query execution plan Use Table variable
inplace of Temp table
SQL keyword in capital
letters
Use Computed columns
for columns for function
SP- Easy Security
Prefixes Name – Think
before use , Ask Why ?
Normalized and DE
normalization
use referential integrity Use UNION ALL inplace
of UNION
Join instead of sub or
nested queries
Use Index hint SP- Test script
Try to use Identity ID
column in all Table
Do not use reserved
words
partitioning large fact
tables
Use Schema name
before SQL objects
Primary Key = Never
enter by user
Stop Waiting Around
Minimize tempdb
Contention
All Passwords should be
Encrypted
Use number in name
only if necessary
partition grain
Keep Transaction small
Fill Factor to 70 percent Locate I/O Bottlenecks
No to Shrinking Data
Files
Standardize Naming
Conventions
Use Custom Schema
Manage statistics
manually SET NOCOUNT ON
update statistics for
large Database
Root Out Problem
Queries
Automation
Normalization of data Use Constraints Appropriate Data Type Use TRY-Catch
Use WITH RECOMPILE if
required
Plan To Reuse SQL Job Monitoring
No wildcard characters
in Any Names
create an index on
Proper Column
Not to overuse nchar
and nvarchar Avoid prefix "sp_" Avoid using cursors Monitor Index Usage Database of Database
Avoid search <> and
NOT
use transactions
Avoid NULL in fixed-
length field
Proper design and
planning
cache redundant data
where appropriate
Separate Data and Log
Files
SQL Script Formatting
Use Derived tables Parallel processing Use EXISTS instead of IN Small Database
documentation
Don’t use triggers
Use Separate Staging
Databases
Use NOLOCK properly
Performance highest
priority while design
Deadlock thought
process
Avoid Having Clause Use Configuration table batch together multiple
concurrent sql queries
avoid numerous round
trips to Database
Write less think more on
TSQL Scripting
• BI Solution Architect
• Blogging @ http://bimentalist.com , http://sqlmentalist.com
• Knowledge sharing - 350+ BI Articles ,400 SQL Article , 350+ SQL Script
• 4 Complex SQL tool innovator on Codeplex & open source all- https://goo.gl/OI3sB4
• Slide share publication - http://www.slideshare.net/VishalPawar_BI
• 2 LinkedIn Post - https://www.linkedin.com/today/author/120635304
• Free Power BI Course publish on Udemy - https://goo.gl/ArL0qe , 1400 + Student
• Leading Global Power BI User Group http://goo.gl/oV7IHz , 1200+ Member , 12 + Leaders
• Professional Microsoft BI Trainer Mentalist Network
• Founder & BI Consulting Partner of Right Click Info
• NMUG Community Founder Leader , Speaker - http://nmug.org/
• Microsoft Community Representative for Navi Mumbai region.
• SQL PASS Chapter Lead for Mumbai & Navi Mumbai
• MCTS: Microsoft® Certified Technology Specialist -SQL Server 2008 R2, BI
• MCSA: Microsoft® Certified Solutions Associate
• CSM: Certified Scrum Master from Scrum Alliance, US
• SQL Server Expert in Architecting and Optimization
• BE - Computer Science & Engineering , RAIT , Mumbai
• MBA-Information System, Arianth College , Pune
About Me

More Related Content

Viewers also liked

E:\Ch Power Point Presentations\Chapter One Jesus Christ And The Foun...
E:\Ch     Power Point Presentations\Chapter One     Jesus Christ And The Foun...E:\Ch     Power Point Presentations\Chapter One     Jesus Christ And The Foun...
E:\Ch Power Point Presentations\Chapter One Jesus Christ And The Foun...
Matt Russick
 

Viewers also liked (14)

Seminario análisis forense - quién se ha llevado mi archivo
Seminario análisis forense  - quién se ha llevado mi archivoSeminario análisis forense  - quién se ha llevado mi archivo
Seminario análisis forense - quién se ha llevado mi archivo
 
Uso racional de Antibioticos
Uso racional de AntibioticosUso racional de Antibioticos
Uso racional de Antibioticos
 
VDV 45x oder Google? / Neue Schnittstellen für den Datenaustausch
VDV 45x oder Google? / Neue Schnittstellen für den DatenaustauschVDV 45x oder Google? / Neue Schnittstellen für den Datenaustausch
VDV 45x oder Google? / Neue Schnittstellen für den Datenaustausch
 
06 calidad optica
06  calidad optica06  calidad optica
06 calidad optica
 
Menor amendment
Menor amendmentMenor amendment
Menor amendment
 
Operación realizada por el Dr. Ramiro Yane Mana
Operación realizada por el Dr. Ramiro Yane ManaOperación realizada por el Dr. Ramiro Yane Mana
Operación realizada por el Dr. Ramiro Yane Mana
 
E:\Ch Power Point Presentations\Chapter One Jesus Christ And The Foun...
E:\Ch     Power Point Presentations\Chapter One     Jesus Christ And The Foun...E:\Ch     Power Point Presentations\Chapter One     Jesus Christ And The Foun...
E:\Ch Power Point Presentations\Chapter One Jesus Christ And The Foun...
 
EcoVadis presentation ES_2016
EcoVadis presentation ES_2016EcoVadis presentation ES_2016
EcoVadis presentation ES_2016
 
Diego Jaramillo, CEO de FHIOS en Academia Inbound
Diego Jaramillo, CEO de FHIOS en Academia InboundDiego Jaramillo, CEO de FHIOS en Academia Inbound
Diego Jaramillo, CEO de FHIOS en Academia Inbound
 
PSA Group : 9 strategic issues for a sustainable development
PSA Group : 9 strategic issues for a sustainable developmentPSA Group : 9 strategic issues for a sustainable development
PSA Group : 9 strategic issues for a sustainable development
 
Configurar programes notepad para Compilar Visual Basic
Configurar programes notepad para Compilar Visual BasicConfigurar programes notepad para Compilar Visual Basic
Configurar programes notepad para Compilar Visual Basic
 
Tema4. curso de Protección del Patrimonio.
Tema4. curso de Protección del Patrimonio.Tema4. curso de Protección del Patrimonio.
Tema4. curso de Protección del Patrimonio.
 
Prader willi - Johana Acosta
Prader willi  - Johana AcostaPrader willi  - Johana Acosta
Prader willi - Johana Acosta
 
The Greatest Story Ever Folded
The Greatest Story Ever FoldedThe Greatest Story Ever Folded
The Greatest Story Ever Folded
 

More from Vishal Pawar

More from Vishal Pawar (20)

Architectural Guidance Connecting HANA Live to Power BI
Architectural Guidance Connecting HANA Live to Power BIArchitectural Guidance Connecting HANA Live to Power BI
Architectural Guidance Connecting HANA Live to Power BI
 
Secrete of 5 min Power BI Report Development
Secrete of 5 min Power BI Report Development Secrete of 5 min Power BI Report Development
Secrete of 5 min Power BI Report Development
 
General Presentation - DIAD and AIAD, Dashboard and Apps
General Presentation - DIAD and AIAD, Dashboard and AppsGeneral Presentation - DIAD and AIAD, Dashboard and Apps
General Presentation - DIAD and AIAD, Dashboard and Apps
 
Pascua Yaqui Tribe App in a day and dashboard in day
Pascua Yaqui Tribe App in a day and dashboard in dayPascua Yaqui Tribe App in a day and dashboard in day
Pascua Yaqui Tribe App in a day and dashboard in day
 
Cherokee nation 2 day AIAD & DIAD - App in a day and Dashboard in day
Cherokee nation 2 day AIAD & DIAD - App in a day and Dashboard in dayCherokee nation 2 day AIAD & DIAD - App in a day and Dashboard in day
Cherokee nation 2 day AIAD & DIAD - App in a day and Dashboard in day
 
Choctaw Nation - Power bi dashboard, report server report in Day
Choctaw Nation - Power bi dashboard, report server report in DayChoctaw Nation - Power bi dashboard, report server report in Day
Choctaw Nation - Power bi dashboard, report server report in Day
 
South Florida SQL Saturday - Power BI Report Server Enterprise Architecture, ...
South Florida SQL Saturday - Power BI Report Server Enterprise Architecture, ...South Florida SQL Saturday - Power BI Report Server Enterprise Architecture, ...
South Florida SQL Saturday - Power BI Report Server Enterprise Architecture, ...
 
Sql Saturday Jacksonville- Power BI Report Server Enterprise Architecture, to...
Sql Saturday Jacksonville- Power BI Report Server Enterprise Architecture, to...Sql Saturday Jacksonville- Power BI Report Server Enterprise Architecture, to...
Sql Saturday Jacksonville- Power BI Report Server Enterprise Architecture, to...
 
Power BI Report Server Enterprise Architecture, Tools to Publish reports and ...
Power BI Report Server Enterprise Architecture, Tools to Publish reports and ...Power BI Report Server Enterprise Architecture, Tools to Publish reports and ...
Power BI Report Server Enterprise Architecture, Tools to Publish reports and ...
 
SqlSaturday#699 Power BI - Create a dashboard from zero to hero
SqlSaturday#699 Power BI - Create a dashboard from zero to heroSqlSaturday#699 Power BI - Create a dashboard from zero to hero
SqlSaturday#699 Power BI - Create a dashboard from zero to hero
 
All Microsoft Azure Service offering Consolidated in one page
All Microsoft Azure Service offering Consolidated in one pageAll Microsoft Azure Service offering Consolidated in one page
All Microsoft Azure Service offering Consolidated in one page
 
Power BI Create lightning fast dashboard with power bi & Its Components
Power BI Create lightning fast dashboard with power bi & Its Components Power BI Create lightning fast dashboard with power bi & Its Components
Power BI Create lightning fast dashboard with power bi & Its Components
 
Groupby -Power bi dashboard in hour by vishal pawar-Presentation
Groupby -Power bi dashboard in hour by vishal pawar-Presentation Groupby -Power bi dashboard in hour by vishal pawar-Presentation
Groupby -Power bi dashboard in hour by vishal pawar-Presentation
 
Power bi dashboard in hour Agenda
Power bi dashboard in hour AgendaPower bi dashboard in hour Agenda
Power bi dashboard in hour Agenda
 
Dashboard for Life Series “Episode 02 - David Kay's Kickstarter Funded Projec...
Dashboard for Life Series “Episode 02 - David Kay's Kickstarter Funded Projec...Dashboard for Life Series “Episode 02 - David Kay's Kickstarter Funded Projec...
Dashboard for Life Series “Episode 02 - David Kay's Kickstarter Funded Projec...
 
Dashboard for Life Series “Episode 1 - Vishal's Server SQL Info Dashboard
Dashboard for Life Series “Episode 1 - Vishal's Server SQL Info DashboardDashboard for Life Series “Episode 1 - Vishal's Server SQL Info Dashboard
Dashboard for Life Series “Episode 1 - Vishal's Server SQL Info Dashboard
 
Power BI for CEO
Power BI for CEOPower BI for CEO
Power BI for CEO
 
Power BI February update with Recent Cool features
Power BI February update with Recent Cool features Power BI February update with Recent Cool features
Power BI February update with Recent Cool features
 
How to Get Lightning Fast Answers with Power BI Q&A and Cortana
How to Get Lightning Fast Answers with Power BI Q&A and CortanaHow to Get Lightning Fast Answers with Power BI Q&A and Cortana
How to Get Lightning Fast Answers with Power BI Q&A and Cortana
 
SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

TSQL coding conventions, best practices, tips and programming guidelines for sql server

  • 1. T-SQLCoding Conventions, Best Practices, Tips and Programming Guidelines BY-VISHAL PAWAR
  • 2. T - SQL Do not use SELECT * Use parametrized queries Create Clustered and Non-Clustered Indexes For enumerated value create look up Table Think SQL injection SP-Stores Procedure Comment well Singular Name for table Avoid side cursors Test - Large databases Keep clustered index small Store image paths or URLs Think usage of functions in WHERE clauses SP-Faster than CRUD Consistent Names Use SET NOCOUNT ON Timeouts Awareness Avoid Cursors Use LIKE clause properly Use set-based solutions SP-Easy Maintenance Don’t use space for names Un normalized – Not Broken Business Entity a query execution plan Use Table variable inplace of Temp table SQL keyword in capital letters Use Computed columns for columns for function SP- Easy Security Prefixes Name – Think before use , Ask Why ? Normalized and DE normalization use referential integrity Use UNION ALL inplace of UNION Join instead of sub or nested queries Use Index hint SP- Test script Try to use Identity ID column in all Table Do not use reserved words partitioning large fact tables Use Schema name before SQL objects Primary Key = Never enter by user Stop Waiting Around Minimize tempdb Contention All Passwords should be Encrypted Use number in name only if necessary partition grain Keep Transaction small Fill Factor to 70 percent Locate I/O Bottlenecks No to Shrinking Data Files Standardize Naming Conventions Use Custom Schema Manage statistics manually SET NOCOUNT ON update statistics for large Database Root Out Problem Queries Automation Normalization of data Use Constraints Appropriate Data Type Use TRY-Catch Use WITH RECOMPILE if required Plan To Reuse SQL Job Monitoring No wildcard characters in Any Names create an index on Proper Column Not to overuse nchar and nvarchar Avoid prefix "sp_" Avoid using cursors Monitor Index Usage Database of Database Avoid search <> and NOT use transactions Avoid NULL in fixed- length field Proper design and planning cache redundant data where appropriate Separate Data and Log Files SQL Script Formatting Use Derived tables Parallel processing Use EXISTS instead of IN Small Database documentation Don’t use triggers Use Separate Staging Databases Use NOLOCK properly Performance highest priority while design Deadlock thought process Avoid Having Clause Use Configuration table batch together multiple concurrent sql queries avoid numerous round trips to Database Write less think more on TSQL Scripting
  • 3. • BI Solution Architect • Blogging @ http://bimentalist.com , http://sqlmentalist.com • Knowledge sharing - 350+ BI Articles ,400 SQL Article , 350+ SQL Script • 4 Complex SQL tool innovator on Codeplex & open source all- https://goo.gl/OI3sB4 • Slide share publication - http://www.slideshare.net/VishalPawar_BI • 2 LinkedIn Post - https://www.linkedin.com/today/author/120635304 • Free Power BI Course publish on Udemy - https://goo.gl/ArL0qe , 1400 + Student • Leading Global Power BI User Group http://goo.gl/oV7IHz , 1200+ Member , 12 + Leaders • Professional Microsoft BI Trainer Mentalist Network • Founder & BI Consulting Partner of Right Click Info • NMUG Community Founder Leader , Speaker - http://nmug.org/ • Microsoft Community Representative for Navi Mumbai region. • SQL PASS Chapter Lead for Mumbai & Navi Mumbai • MCTS: Microsoft® Certified Technology Specialist -SQL Server 2008 R2, BI • MCSA: Microsoft® Certified Solutions Associate • CSM: Certified Scrum Master from Scrum Alliance, US • SQL Server Expert in Architecting and Optimization • BE - Computer Science & Engineering , RAIT , Mumbai • MBA-Information System, Arianth College , Pune About Me