Showing posts with label default. Show all posts
Showing posts with label default. Show all posts

Wednesday, March 21, 2012

how do I get the value of a DEFAULT

Hi

We have a default defined in our database

CREATE DEFAULT [ schema_name . ] default_name
AS constant_expression [ ; ]

How can I ge the value of the constant using SQL ?

Also - anyone know why this is going to be removed from a future version of SQL - we use it for partitioning with replicated clients (long story) - but every table has one column which is bound to this default. We find it *very* handy.

Ta
Bruce

take a look at the sys.default_constraints catalog view, the definition column will have the value

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||We are recommending that you use default constraints instead of DEFAULTs. Would that not work for you?|||

If we were starting the project now, then yes, but we have many installations around the globe relying on this feature....

Bruce

|||

That shows the default constraints, but not our DEFAULT (terminology so similar but different - I'm confused!)

thanks
bruce

|||

sp_helpconstraint tablename

Adamus

|||

Thats closer, but I really just want to know that the integer value of my DEFAULT is ...

I see it joins on sys.columns and syscomments to get a descriptive string of the default - I was hoping for something a little more direct - in the meantime I'll write a function to work it out..

thanks

|||

syscomments is deprecated in sql server 2005. Please use sys.sql_modules instead or you can use the below built-in object_definition.

select object_definition(default_object_id) from sys.columns where default_object_id <> 0

|||

SELECT d.* FROM sys.default_constraints as d
JOIN sys.objects as o
ON o.object_id = d.parent_object_id
JOIN sys.columns as c
ON c.object_id = o.object_id AND c.column_id = d.parent_column_id
JOIN sys.schemas as s
ON s.schema_id = o.schema_id
WHERE o.name='<TableName>' AND c.name = '<ColumnName>'

The above query will show the default constraint properties of the column specified in the above query.

The default value can be obtained from the column d.[definition] in the above query.

Thanks,
Loonysan

sql

Wednesday, March 7, 2012

How do i enter NULL in a table cell in the Enterprise Manager UI for table data entry?

I have a column defined as smalldatetime. Default length (4), and "allow NULLS" is checked.
In the Enterprise Manager UI, when i enter data into that table row, if i just tab past that column, all is well, and the value is represented in the UI as <NULL>.
The problem comes once i ever enter a date into that column. Say i have entered a date (all is well), and now i want to remove that entry and go back to NULL (after the date value has been committed, different entry session, say).
How is that done?
It seems to me, once a date has ever been entered into that column, now, if i try to remove it, i get the error "The value you entered is not consistant with the data type or length of the column, or over grid buffer limit". I have tried deleting the value, entering spaces, entering the string NULL or the string <NULL>; maybe some other tries as well, but none works, i always get that error message and am not allowed to proceed past that cell until i restore a date value to it. I want to get back to <NULL>.
Anybody know?
Thank you.
Tom

CTRL + 0 will do it.

How do I enable this permently?

http://support.microsoft.com/default...b;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after =
you install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4. =
Thanks.
--=20
George Hester
_________________________________
Upgrade the clients to the same service pack levels.
Sincerely,
Anthony Thomas

"George Hester" <hesterloli@.hotmail.com> wrote in message
news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
http://support.microsoft.com/default...b;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after you
install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4.
Thanks.
George Hester
_________________________________
|||I'm not sure what you mean? What clients? I have Visual Studio 6 SP5 =
SQL 2000 SP3 and Windows 2000 SP4. I'm not really looking to change =
that configuration. Can't it be done with a startup parameters or =
something? Thanks.
--=20
George Hester
_________________________________
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message =
news:uAdpeE58EHA.1204@.TK2MSFTNGP10.phx.gbl...
> Upgrade the clients to the same service pack levels.
>=20
> Sincerely,
>=20
>=20
> Anthony Thomas
>=20
>=20
> --=20
>=20
> "George Hester" <hesterloli@.hotmail.com> wrote in message
> news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
> http://support.microsoft.com/default...b;en-us;328151
>=20
> <The T-SQL Debugger is turned off by default for earlier clients after =
you
> install SQL Server 2000 Service Pack 3>
>=20
> SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 =
SP4.
> Thanks.
>=20
> --=20
> George Hester
> _________________________________
>=20
>=20

How do I enable this permently?

http://support.microsoft.com/defaul...kb;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after =
you install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4. =
Thanks.
--=20
George Hester
_________________________________Upgrade the clients to the same service pack levels.
Sincerely,
Anthony Thomas
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
http://support.microsoft.com/defaul...kb;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after you
install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4.
Thanks.
George Hester
_________________________________|||I'm not sure what you mean? What clients? I have Visual Studio 6 SP5 =
SQL 2000 SP3 and Windows 2000 SP4. I'm not really looking to change =
that configuration. Can't it be done with a startup parameters or =
something? Thanks.
--=20
George Hester
_________________________________
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message =
news:uAdpeE58EHA.1204@.TK2MSFTNGP10.phx.gbl...
> Upgrade the clients to the same service pack levels.
>=20
> Sincerely,
>=20
>=20
> Anthony Thomas
>=20
>=20
> --=20
>=20
> "George Hester" <hesterloli@.hotmail.com> wrote in message
> news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
> http://support.microsoft.com/defaul...kb;en-us;328151
>=20
> <The T-SQL Debugger is turned off by default for earlier clients after =
you
> install SQL Server 2000 Service Pack 3>
>=20
> SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 =
SP4.
> Thanks.
>=20
> --=20
> George Hester
> _________________________________
>=20
>=20

How do I enable this permently?

http://support.microsoft.com/default.aspx?scid=3Dkb;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after = you install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4. = Thanks.
-- George Hester
_________________________________Upgrade the clients to the same service pack levels.
Sincerely,
Anthony Thomas
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
http://support.microsoft.com/default.aspx?scid=kb;en-us;328151
<The T-SQL Debugger is turned off by default for earlier clients after you
install SQL Server 2000 Service Pack 3>
SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 SP4.
Thanks.
--
George Hester
_________________________________|||I'm not sure what you mean? What clients? I have Visual Studio 6 SP5 =SQL 2000 SP3 and Windows 2000 SP4. I'm not really looking to change =that configuration. Can't it be done with a startup parameters or =something? Thanks.
-- George Hester
_________________________________
"AnthonyThomas" <Anthony.Thomas@.CommerceBank.com> wrote in message =news:uAdpeE58EHA.1204@.TK2MSFTNGP10.phx.gbl...
> Upgrade the clients to the same service pack levels.
> > Sincerely,
> > > Anthony Thomas
> > > -- > > "George Hester" <hesterloli@.hotmail.com> wrote in message
> news:eMNKmw48EHA.3944@.TK2MSFTNGP12.phx.gbl...
> http://support.microsoft.com/default.aspx?scid=3Dkb;en-us;328151
> > <The T-SQL Debugger is turned off by default for earlier clients after =you
> install SQL Server 2000 Service Pack 3>
> > SQL 2000 SP3, Microsoft Vicual Studio 6 SP5, Microsoft Windows 2000 =SP4.
> Thanks.
> > -- > George Hester
> _________________________________
> >=20