Sunday, February 26, 2012

Domains in SQL Server?

Hello all,
I've worked mostly with FirebirdSQL and Firebird has a nifty little
feature called "domains" which are basically pre-defined field types
which can included native field type (int, varchar, etc), constraints,
etc. Instead of defining an Int field with a default value of zero
that must be between 1 and 100000 everytime you need that kind of
field, you can just create that domain and assign that domain as a
field/column type when created a table.
This is a time saver as well as making data types standardized in my
database.
Is there an equivelant in SQL Server?
Warm Regards,
Lee
"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
Yes, User Defined Data Types.
Have a look in SQL Books On Line for sp_addtype
You will need to bind a rule to your UDDT with the syntax "CREATE RULE" to
fully implement what you're after
HTH. Ryan
"Lee" <luv2program2000@.yahoo.com> wrote in message
news:Ox7G4Y4GGHA.532@.TK2MSFTNGP15.phx.gbl...
>
> Hello all,
> I've worked mostly with FirebirdSQL and Firebird has a nifty little
> feature called "domains" which are basically pre-defined field types
> which can included native field type (int, varchar, etc), constraints,
> etc. Instead of defining an Int field with a default value of zero
> that must be between 1 and 100000 everytime you need that kind of
> field, you can just create that domain and assign that domain as a
> field/column type when created a table.
> This is a time saver as well as making data types standardized in my
> database.
> Is there an equivelant in SQL Server?
>
> --
> Warm Regards,
> Lee
> "Upon further investigation it appears that your software is missing
> just one thing. It definitely needs more cow bell..."
|||Ryan enlightened me by writing:

> Yes, User Defined Data Types.
> Have a look in SQL Books On Line for sp_addtype
> You will need to bind a rule to your UDDT with the syntax "CREATE
> RULE" to fully implement what you're after
Excellent.
Thanks Ryan
Warm Regards,
Lee
"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
|||But you should be aware that Default and Rule objects (they you tie to user defined datatypes, or
"alias datatypes" as they are called in 2005) are deprecated in 2005. This means that Default and
Rule objects will be removed in some future version of SQL Server (in favor for Constraints).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Lee" <luv2program2000@.yahoo.com> wrote in message news:%23YmZyu4GGHA.216@.TK2MSFTNGP15.phx.gbl...
> Ryan enlightened me by writing:
>
> Excellent.
> Thanks Ryan
> --
> Warm Regards,
> Lee
> "Upon further investigation it appears that your software is missing
> just one thing. It definitely needs more cow bell..."

No comments:

Post a Comment