Solved

Retrieving Default Value of a Field using T-SQL

Posted on 2007-04-09
2
218 Views
Last Modified: 2010-03-19
Is there a way of accessing the default value for a field from tSQL?

I relize you could clear a new record, check the value and then delete the record, but that seems an expensive way of doing it.

Creating a record default could work, but if you changed the default in the table then it would be wrong.

Any way of accessing the value directly?
0
Comment
Question by:randymiller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 18878303
0
 
LVL 10

Assisted Solution

by:ksaul
ksaul earned 250 total points
ID: 18878377
SELECT c.name ColumnName,  com.text Default
FROM syscolumns c
INNER join sysobjects o on c.id = o.id
INNER join syscomments com on c.cdefault = com.id
WHERE o.name = 'YourTable' and c.name = 'YourColumn'
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question