Showing posts with label bound. Show all posts
Showing posts with label bound. Show all posts

Friday, March 9, 2012

how to find out if a column has a default (sp_bindefault)

How do I find out if a column has a default bound to it (created with
sp_bindefault)?See if you can massage the query below:
SELECT c.name, OBJECT_NAME(c.cdefault)
FROM syscolumns c
WHERE OBJECTPROPERTY(c.cdefault, 'IsConstraint') = 1 ;
Anith|||Jacobus Terhorst wrote:
> How do I find out if a column has a default bound to it (created with
> sp_bindefault)?
It's undocumented and not supported, but you can use sp_MShelpcolumns.
Have a look at the text column.
create table A12345 (
col1 int not null default 5,
col2 nvarchar(10) not null default N'ABC')
exec sp_MShelpcolumns N'[dbo].[A12345]', @.orderby = 'id'
go
Drop Table A12345
Go
David Gugick
Imceda Software
www.imceda.com|||Thank you!
Jacobus Terhorst
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:uMDkACpJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> See if you can massage the query below:
> SELECT c.name, OBJECT_NAME(c.cdefault)
> FROM syscolumns c
> WHERE OBJECTPROPERTY(c.cdefault, 'IsConstraint') = 1 ;
> --
> Anith
>