SQL SERVER – Puzzle – Brain Teaser – Changing Data Type is Changing the Default Value

Changing the Default Value is the question behind this data-type puzzle. I keep the expression, data type and nullability separate.

A clay blank and two differently shaped molds sit beside a fitted sample.

Start with data type A and default expression B. Change the column to type C without intentionally changing the default expression. The resulting value in this scenario is D. D differs from B.

  1. Identify the original type A and default B.
  2. Identify the new type C and resulting default value D.

Include a small reproducible script with the actual constraint definition. Show the stored result as well. That helps distinguish a changed definition from conversion or display behavior.

The challenge doesn’t assert that ALTER COLUMN silently rewrites every default constraint. Explain the specific scenario and its assumptions. The comment-holding deadline belonged to the original 2017 event.

A different displayed value is not proof of a rewritten default, it is a result that needs explanation.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Column, SQL Datatype, SQL NULL, SQL Server
Previous Post
Adding Two Dates in SQL Server: Why the Year Is 2126
Next Post
SQL SERVER – Puzzle – Why Does UNION ALL Work but UNION Produces Error?

Related Posts

18 Comments. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.