Find Column Default Value using T-SQL – SQL Server

Here’s how to find the default value of a Column using T-SQL. We will find the default value of the UnitPrice column in the Products table of the Northwind database

SELECT object_definition(default_object_id) AS DefaultValue
FROM sys.columns
WHERE name = 'UnitPrice'
AND object_id = object_id('Products')

OUTPUT

image

No comments:

Post a Comment