Home All Groups Group Topic Archive Search About

System catalog - defaults

Author
7 Apr 2006 1:25 AM
lh
How can I check for the default value of a column?

I can get to sysobjects where type='D' but I want to find what the value of
the default is.

TIA - LH

Author
7 Apr 2006 1:41 AM
lh
forget I asked, information_schema.columns



Show quoteHide quote
"lh" <l*@nowhere.com> wrote in message
news:5ajZf.322$b6.8082@nasal.pacific.net.au...
> How can I check for the default value of a column?
>
> I can get to sysobjects where type='D' but I want to find what the value
> of the default is.
>
> TIA - LH
>
Are all your drivers up to date? click for free checkup

Author
7 Apr 2006 2:05 AM
Uri Dimant
lh
CREATE TABLE fff
(
    col1 INT NOT NULL DEFAULT 5,
    col2 INT
)
GO

ALTER TABLE fff
    ADD CONSTRAINT myConstraint DEFAULT 5 FOR b
GO

SELECT scobj.name, cols.name
FROM sysconstraints sc
INNER JOIN sysobjects scobj
ON sc.constid = scobj.id
AND sc.id=OBJECT_ID('fff')
INNER JOIN syscolumns cols
ON sc.id = cols.id
AND sc.colid = cols.colid
GO

---value
SELECT text FROM syscomments
WHERE id=OBJECT_ID('myConstraint')



Show quoteHide quote
"lh" <l*@nowhere.com> wrote in message
news:5ajZf.322$b6.8082@nasal.pacific.net.au...
> How can I check for the default value of a column?
>
> I can get to sysobjects where type='D' but I want to find what the value
> of the default is.
>
> TIA - LH
>

Bookmark and Share