Thanks for the easy solution.
"Andrea Montanari" <andrea.sqlDMO@virgilio.it> wrote in message
news:32iumjF3lhedjU1@individual.net...
> hi Prabhat,
> "Prabhat" <not_a_mail@hotmail.com> ha scritto nel messaggio
> news:ex0hP0Q5EHA.2804@TK2MSFTNGP15.phx.gbl
> > Hi All,
> >
> > Is there any way we could find out the NAME of the default that is
> > binded to a column on a table?
> >
> > Ex: -
> >
> > Create Table EMP
> > (
> > EmpID int identity(100, 1),
> > ename varchar(25),
> > sal decimal(18,2) default 0
> > )
> >
> > So Here How Do I find the Name of the Default that is assigned to SAL
> > Column. (I know that I can see that using SP_HELP, But How do I store
> > that Value in a Variable from a SYSTEM TABLE?)
> >
> > And IS there a Way to Give the Default Name in column definations?
> > (Not using the sp_binddefault)
> >
> > Thanks
> > Prabhat
>
> actually you can, specifying CONSTRAINT constraint_naim DEFAULT value, as
> you can remove and re-add it using ALTER TABLE syntax
>
> SET NOCOUNT ON
> USE tempdb
> CREATE TABLE test (
> ID INT CONSTRAINT ID_DEFAULT DEFAULT 1
> )
> GO
>
> /* ----- WARNING ----*/
> /* use of sysobjects and syscolumns system tables */
> /* in order to inspect for DEFAULT name based on */
> /* table name and column name */
>
> SELECT o1.name
> FROM sysobjects o1 JOIN syscolumns c
> ON o1.id = c.cdefault
> JOIN sysobjects o2
> ON o1.parent_obj = o2.id
> WHERE (o2.name = 'test' ) AND (c.name = 'id')
> GO
> ALTER TABLE test
> DROP CONSTRAINT ID_DEFAULT
> GO
> ALTER TABLE test
> ADD CONSTRAINT DEF_new_def_for_col_ID DEFAULT 10 FOR ID
> GO
> SELECT o1.name
> FROM sysobjects o1 JOIN syscolumns c
> ON o1.id = c.cdefault
> JOIN sysobjects o2
> ON o1.parent_obj = o2.id
> WHERE (o2.name = 'test' ) AND (c.name = 'id')
>
> GO
> DROP TABLE test
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
>
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org > DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> --------- remove DMO to reply
>