Unix Technical Forum

User Defined Data Types Problem

This is a discussion on User Defined Data Types Problem within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi all, I defined unsigned_int in my database, which uses unsigned_int_range rule. The unsigned_int_range rule is defined as follows: ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:52 PM
royaldothighness@hotmail.com
 
Posts: n/a
Default User Defined Data Types Problem

Hi all,

I defined unsigned_int in my database, which uses unsigned_int_range
rule. The unsigned_int_range rule is defined as follows:
@unsigned_int >=0 and @unsigned_int <=4294967295

(4294967295 = 0xFFFFFFFF)

The storage size is 4 bytes.

One of the tables in the database contains a field that is of type
unsigned_int.

When I try to add a new record into the table (ex: using the Enterprise
Manager), it always fails in the unsigned_int field if I enter a value
greater than 2147483647 (which is 0x7FFFFFFF) all the way to 4294967295
(0xFFFFFFFF). The Enterprise Manager shows the following message:

"The value you entered is not consistent with the data type or
length of the column, or over grid buffer limit."

What is wrong here? The 4-byte storage should be good for any value
from 0 to 4294967295.

Any help is appreciated.

Thanks,
Ken

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:52 PM
Erland Sommarskog
 
Posts: n/a
Default Re: User Defined Data Types Problem

royaldothighness@hotmail.com (royaldothighness@hotmail.com) writes:
> I defined unsigned_int in my database, which uses unsigned_int_range
> rule. The unsigned_int_range rule is defined as follows:
> @unsigned_int >=0 and @unsigned_int <=4294967295
>
> (4294967295 = 0xFFFFFFFF)
>
> The storage size is 4 bytes.
>
> One of the tables in the database contains a field that is of type
> unsigned_int.
>
> When I try to add a new record into the table (ex: using the Enterprise
> Manager), it always fails in the unsigned_int field if I enter a value
> greater than 2147483647 (which is 0x7FFFFFFF) all the way to 4294967295
> (0xFFFFFFFF). The Enterprise Manager shows the following message:
>
> "The value you entered is not consistent with the data type or
> length of the column, or over grid buffer limit."
>
> What is wrong here? The 4-byte storage should be good for any value
> from 0 to 4294967295.


Since you mention Enterprise Manager, I assume that you use SQL 2000.

To define a user-defined data type with that range you would have to
to base it on bigint or decimal(10, 0). You cannot use int as a base,
since int is signed.

In SQL 2005, you could define your unsigned int throught the CLR, although
I doubt that it would be worth the pain.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:52 PM
Alexander Kuznetsov
 
Posts: n/a
Default Re: User Defined Data Types Problem

Ken,

If you want both 4 byte storage and 0 to 4294967295 range, you could
store an int stored_value = (your_value - 2147483648) and have a
computed column (cast(stored_value as bigint) + 2147483648). Not sure
if saving 4 bytes of storage is worth the effort in your case, but
sometimes it definitely is worth trying.

Good luck!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com