This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Padded sleeve board supporting a jacket sleeve beside an unsupported sleeve

Column Aliases: Where You Can Use Them and Where You Cannot

June 8, 2014
Pinal Dave
SQL Tips and Tricks
SQL Coding Standards, SQL Column, SQL Order By

Why does WHERE say the alias does not exist? Here is the order SQL Server follows, two clean fixes and one quiet trap to avoid.

Read More
A new wooden shelf unit standing on a workshop floor beside a small dish of wooden pegs, one red peg nearby.

Designing Your First Table: Columns, Keys and Data Types

September 1, 2013
Pinal Dave
SQL Tips and Tricks
Primary Key, SQL Column, SQL Constraint and Keys, SQL Datatype, SQL Table Operation

Designing Your First Table gets easier when you decide what it must hold before you write any SQL. This post walks through naming, data types, NULL or NOT NULL, a primary key, a default and a check constraint on a small Customers table. It also shows what to leave for later.

Read More
A wooden seed tray seen from above with rows and columns of small green seedlings, one cell marked with a red stick.

Rows, Columns and Tables: How a Database Holds Information

August 21, 2013
Pinal Dave
SQL Tips and Tricks
Database, SQL Column, SQL Constraint and Keys, SQL Data Storage, SQL Table Operation

Rows, Columns and Tables are the three ideas behind every relational database. A table holds one kind of thing, a column describes one fact about it, and a row records one item. This post builds a small Books table in SQL Server and reads it back by row and by column.

Read More
A hand raising a single vermilion pennant on a flagpole above a harbor full of moored boats.

Adding a NOT NULL Column With a Default to a Big Table

May 1, 2013
Pinal Dave
SQL Tips and Tricks
DBA, SQL Column, SQL Constraint and Keys, SQL Server, SQL Table Operation

Add a NOT NULL column with a default safely, distinguish metadata changes from row updates, and plan a staged Standard edition rollout.

Read More
Gouache painting of a xylophone with one new red bar fitted into the middle of the row

How to Add Column at Specific Position in SQL Server

March 11, 2013
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server, SQL Server Management Studio

To add column at specific position in SQL Server, you have three tested options, because ALTER TABLE always adds the column last. This post shows a SELECT list, a view for loads and reports, and a full table rebuild. It also explains what the rebuild costs.

Read More
Gouache painting of a wooden boat with a bare stern panel and a pot of red paint with a brush waiting beside it

Rename a Column or Table in SQL Server Safely

November 14, 2012
Pinal Dave
SQL Tips and Tricks
SQL Column, SQL Scripts, SQL Server Management Studio, SQL Table Operation

To rename a column in SQL Server, call sp_rename with the table and column name, the new name and the word COLUMN. This post tests the rename on a demo database and shows what it leaves behind: a broken view, an old constraint name and permissions that stay. It ends with a safe way to swap two column names.

Read More
A plumber's hands fitting a brass valve into a central copper pipe, with branch pipes running off to different rooms.

Renaming a Column Safely Everywhere It Is Used

October 1, 2012
Pinal Dave
SQL Tips and Tricks
Best Practices, SQL Column, SQL Server, SQL Stored Procedure, SQL View

Renaming a column safely requires finding SQL and application references, applying sp_rename, refreshing modules, and testing every consumer.

Read More
Previous 1 … 3 4 5 6 7 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com