Tutorials
DBA
Dev
BI
Career
Categories
Webcasts
Whitepapers
Today's Tip
Join
Tutorials
DBA
Dev
BI
Categories
Webcasts
DBA
Dev
BI
Categories
SQL Server T-SQL Tips
Browse Categories
Aggregates
Application Development
Change Data Capture
Constraints
Data Science
Data Types
Database Design
Dates
Debugging
DevOps
Dynamic Management Views
Dynamic SQL
Encryption
Entity Framework
Error Handling
Excel Integration
Full Text Search
Functions - System
Functions - User Defined
Identities
Import and Export
In-Memory OLTP
JOIN Tables
LINQ
Microsoft Access
Microsoft Flow
Paging
Power BI
Python
Query Optimization
Query Plans
Scripts
Service Broker
Spatial Data Storage
SQL Injection
SQL Mgmt Objects (SMO)
Stored Procedures
Synonyms
T-SQL
Table Valued Parameters
Temporal Tables
Testing
Transactions
Triggers
User Defined Type UDT
Views
XML
Aggregate
Concat Aggregates SQL Server CLR Function
Multi parameter CLR aggregate in SQL Server 2005
T-SQL: Capture Related Data and Return By Aggregates
Backward Compatibility
Make your SQL Server database changes backward compatible when adding a new column
Make your SQL Server database changes backward compatible when changing a relationship
Make your SQL Server database changes backward compatible when dropping a column
Make your SQL Server database changes backward compatible when renaming an entity
Calculations
Avoiding erroneous results when using T-SQL Trigonometric Functions in SQL Server 2012
Calculating and verifying financial values in SQL Server
Calculating Mathematical Values in SQL Server
Calculating the Pearson Product Moment Correlation Coefficient in T-SQL
Getting a SQL Server RowCount Without doing a Table Scan
Min-Max Normalization in T-SQL when the Boundaries are not [0,1]
Mining Time Series Data by Calculating Moving Averages with T-SQL Code in SQL Server
Mining Time Series with Exponential Moving Averages in SQL Server
Script to calculate the Median value for SQL Server data
Select min and max values along with other SQL Server columns using T-SQL
SQL Server T-SQL Code to Return Consecutive Values Over a Certain Value
Summarize Metrics with SQL Server T-SQL Code
T-SQL Bitwise Operators in SQL Server
The SQL Server Numbers Table, Explained - Part 1
The SQL Server Numbers Table, Explained - Part 2
Transforming Cartesian Coordinates to Spherical Coordinates in SQL Server with T-SQL
Use a CrossJoin to Calculate Multiple Pearson Correlation Coefficients in T-SQL
Using a SQL Server Case Statement for IF/Else Logic
Using T-SQL to find the Greatest Common Divisor (GCD) for any number of integers
Using T-SQL to Perform Z-Score Column Normalization in SQL Server
Comparison
Easy way to compare SQL Server table schemas
Simple T-SQL Code Comparison With PowerShell
Computed Columns
Change All Computed Columns to Persisted in SQL Server
Getting creative with Computed Columns in SQL Server
What Effect Does Persisting a Computed Column Have in SQL Server?
What Happens When a Computed Column is Persisted in SQL Server?
Configuration
Determining SET Options for a Current Session in SQL Server
Limit amount of data returned with the SQL Server TEXTSIZE command
Consolidation
Integrating SQL Server Data Using Union, Case and Cast in T-SQL
Data
A T-SQL Model for Contrasting Two Different Sets of Measurement
Pass Historical Data for Stocks from Google Finance to SQL Server
PowerShell and Text Mining Part I: Word Counts, Positions and Libraries
Query for pair-wise relationships between rows for a SQL Server table
Reporting Techniques With SQL Server Text Mining (Part II)
SQL Server Data Mining Strategies for Stock Buy and Sell Recommendations
SQL Server Min Max Column Normalization for Data Mining
SQL Server Rowversion Functions min_active_row_version vs. @@DBTS
T-SQL to Calculate Buy and Sell Stock Recommendations via Three Technical Indicators
Two T-SQL Alternatives For Tracking Changes
Using SQL Server Data Analysis for Stock Trading Strategies
Using T-SQL to Detect Golden Crosses and Death Crosses
Using T-SQL to find the shortest distance between two points
Using T-SQL to Perform Decimal Scaling Normalization for SQL Server
Using T-SQL to Refine an Analytical Model for Picking Stocks
Data Mining
An Overview of Data Science for Stock Price Analysis with SQL: Part 1
Analyzing When to Buy and Sell Stocks Using T-SQL in SQL Server
Assessing with SQL and Data Science Goodness of Fit to Different Distributions
Contingency Table Analysis via Chi Square using T-SQL: Part 1
How to Compare and Combine Artificial Intelligence Models with T-SQL
Mining Stock Price Time Series with MACD in SQL Server
T-SQL Techniques For Mapping Ceteris Paribus Variables
Using SQL to Assess Goodness of Fit to Normal and Uniform Distributions
Using T-SQL to Assess Goodness of Fit to an Exponential Distribution
Using T-SQL to Detect Stock Price Reversals with the RSI
Using T-SQL to Quantify Trend Direction and Strength
Using Two Samples to Validate MACD with T-SQL
Data Tier
Introduction to Data Tier Applications in SQL Server 2008 R2
Data Types
Overview of WITH RESULT SETS Feature of SQL Server 2012
SQL Server Bitwise operators to store multiple values in one column
Delete
Best Practices For Deleting SQL Server Data
Delete Files with SQL Server 2016 R Logic in T-SQL Code
Deleting Data in SQL Server with TRUNCATE vs DELETE commands
Differences between Delete and Truncate in SQL Server
SQL Server Stored Procedure to Safely Delete Data
Development
Do tabs vs. spaces affect performance in SQL Server?
Document Management
Implement a Comment Based Help Framework via CLR Stored Procedure
Duplicate Data
Delete duplicate rows with no primary key on a SQL Server table
Removing Duplicates from Strings in SQL Server
Dynamic
Dynamically build a multi OR with LIKE query for SQL Server
Export
Convert SQL Server Base64 Encoded Text to Images
Formatting
Standardize SQL Server T-SQL Code Formatting
Functions
Find MAX value from multiple columns in a SQL Server table
Write more compact SQL Server code using new features
Write More Compact SQL Server Code Using New Features - Part 2
Locking
Comparison of SQL Server Serializable and Snapshot isolation levels
Merge
Comparing performance for the MERGE statement to SELECT, INSERT, UPDATE or DELETE
Merge parent and child SQL Server tables that use identity keys
Resolving the MERGE statement attempted to UPDATE or DELETE the same row more than once error
SQL Server 2008 MERGE More than UPSERT
SQL Server MERGE statement usage and examples
Use Caution with SQL Server's MERGE Statement
Using MERGE in SQL Server to insert, update and delete at the same time
Using the SQL Server MERGE Statement to Process Type 2 Slowly Changing Dimensions
OUTPUT
SQL Server 2008 consume output directly from the OUTPUT command
Using INSERT OUTPUT in a SQL Server Transaction
Overview
Introduction to Subqueries in SQL Server
Performance
Optimize Large SQL Server DML Processes by Using Batches
Optimize Large SQL Server Insert, Update and Delete Processes by Using Batches
Script to Capture Performance Stats When Testing SQL Server T-SQL Statements
SQL Server CTE vs Temp Table vs Table Variable Performance Test
SQL Server Query Performance for INSERT SELECT vs INSERT EXEC
Testing SQL Server Performance of Database Inserts and Updates
Permissions
Minimum Permissions for SQL Server TRUNCATE TABLE
Pivot
Script to create dynamic PIVOT queries in SQL Server
Use SQL Server's UNPIVOT operator to dynamically normalize output
Use SQL Server's UNPIVOT operator to help normalize output
Plan Cache
Keeping data available in the SQL Server data cache with PINTABLE
Random Data
A More Versatile SQL Server Random Number Function
Executing Code Every Nth Percent of the Time with T-SQL
Generating Random Numbers in SQL Server Without Collisions
SQL Server Function to Generate Random Numbers
SQL Server Random Sorted Result Set
SQL Server stored procedure to generate random passwords
Result Set
Rolling up multiple rows into a single row and column for SQL Server data
SQL Server 2008 Group By Sets
Rollback
Safeguard to Avoid Costly Mistakes for UPDATE or DELETE Statements in SQL Server Management Studio
Scripts
Execute a Command in the Context of Each Database in SQL Server - Part 2
Execute a Command in the Context of Each Database in SQL Server using sp_ineachdb
Generic Approach to Identify Modified SQL Server Rows
Scripts to Build a Network of Connected Records Using SQL Server
Search
How to make SQL Server Wildcard Searches Faster
Security
Preventing TSQL code from running on a Production SQL Server
Sorting
Advanced Use of the SQL Server ORDER BY Clause
Different Methods to Sort SQL Server Result Sets
Statistics
A One-Way Analysis of Variance Test Add-on for the SQL Statistics Package
A Two-Way Analysis of Variance Test Add-on for the SQL Statistics Package
Calculating Median Absolute Deviation with T-SQL Code in SQL Server
Finding Spreads in Data Ranges Using T-SQL
Matrix Multiplication Calculated with T-SQL
SQL Server T-SQL Code for the Tukey Honestly Significant Difference Test After an ANOVA
T-Test Add-on for the SQL Statistics Package
Using T-SQL for Finding Narrowing Ranges of Data
Storage
Get SQL Server Row Count and Space Used with the sp_rows
Strings
Examples and Function for Using SQL Server LIKE Operator and Wildcard Characters
System
Auto Rename SQL Server Tables and Their References with PowerShell
Dropping multiple SQL Server objects with a single DROP statement
Renaming SQL Server database objects and changing object owners
SQL Server Four part naming
SQL Server sp_ prefix when and when not to use it
System Objects
New SQL Server sp_helptext to avoid line splits of code
Temp Tables
Create SQL Server temporary tables with the correct collation
Differences between SQL Server temporary tables and table variables
Exploring SQL Server 2014 Table Variables
SQL Server Global Temporary Table Visibility
SQL Server Performance of SELECT INTO vs INSERT INTO for temporary tables
SQL Server Temp Table vs Table Variable Performance Testing
Troubleshooting
Handling Transactions in Nested SQL Server Stored Procedures
Problem using DISTINCT in case insensitive SQL Server databases
Silent Truncation of SQL Server Data Inserts
SQL Server work around for Msg 2714 There is already an object named #temp in the database
Top 5 Reasons for Wrong Results in SQL Server
Tutorials
Advice for Learning T-SQL SELECT Statement Step By Step
New SQL Server Database Development Tutorial
SQL Server Insert Tutorial
SQL Server SELECT Tutorial
Understand how SQL Server works to write better T-SQL queries
Update
More efficient SQL Server UPDATE for VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data types with the WRITE Clause
Swap SQL Server column data due to inserting data into wrong columns
Variables
Nullability settings with select into and variables
SQL Server 2008 Inline variable initialization and Compound assignment
When to use SET vs SELECT when assigning values to variables in SQL Server
More SQL Server Solutions