I have a procedure that detarmines the maximum current values of user table
attributes. However I don't know how to use SQL to get the maximum value of
a
datatype. Can anyone help?There's no way to get them via SQL AFAIK, but you can just look them up in
Books Online, under the specific datatypes.
Jacco Schalkwijk
SQL Server MVP
"marcmc" <marcmc@.discussions.microsoft.com> wrote in message
news:247D52AD-2959-493F-9DC5-E38E6F031EF7@.microsoft.com...
>I have a procedure that detarmines the maximum current values of user table
> attributes. However I don't know how to use SQL to get the maximum value
> of a
> datatype. Can anyone help?|||To add to Jacco's response, you can also get the min/max permissible values
for numeric types in .Net application code using constants in the
System.Data.SqlTypes namespace (e.g. SqlInt32.MaxValue).
Hope this helps.
Dan Guzman
SQL Server MVP
"marcmc" <marcmc@.discussions.microsoft.com> wrote in message
news:247D52AD-2959-493F-9DC5-E38E6F031EF7@.microsoft.com...
>I have a procedure that detarmines the maximum current values of user table
> attributes. However I don't know how to use SQL to get the maximum value
> of a
> datatype. Can anyone help?|||try looking at the system table systypes
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"marcmc" wrote:
> I have a procedure that detarmines the maximum current values of user tabl
e
> attributes. However I don't know how to use SQL to get the maximum value o
f a
> datatype. Can anyone help?|||Thx
So you can't get them in SQL? How then does it know ehen they are exceeded?
"Dan Guzman" wrote:
> To add to Jacco's response, you can also get the min/max permissible value
s
> for numeric types in .Net application code using constants in the
> System.Data.SqlTypes namespace (e.g. SqlInt32.MaxValue).
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "marcmc" <marcmc@.discussions.microsoft.com> wrote in message
> news:247D52AD-2959-493F-9DC5-E38E6F031EF7@.microsoft.com...
>
>|||> So you can't get them in SQL? How then does it know ehen they are
exceeded?
because the engine is not written in tsql.|||I know that it's not recommended to query system tables directly, but isn't
the information accessible through the systypes table.
INT is listed with a length of 4 but you can easily calculate the max and
min values from this.
The problem that I see would be that Microsoft modifies this table in the
future.
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message news:ustFpMBQFHA.3544@.TK2MSFTNGP12.phx.gbl...
> There's no way to get them via SQL AFAIK, but you can just look them up in
> Books Online, under the specific datatypes.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "marcmc" <marcmc@.discussions.microsoft.com> wrote in message
> news:247D52AD-2959-493F-9DC5-E38E6F031EF7@.microsoft.com...
>|||Because an overflow exception is thrown by the engine.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"marcmc" <marcmc@.discussions.microsoft.com> wrote in message
news:E68737B1-89BA-4915-A1F0-EF816A91DF05@.microsoft.com...
> Thx
> So you can't get them in SQL? How then does it know ehen they are
> exceeded?
>
> "Dan Guzman" wrote:
>|||I know of no way to get this info in Transact-SQL. The characteristics of
built-in datatypes are hard-coded in the engine code so these don't need to
be stored as meta-data or exposed.
Hope this helps.
Dan Guzman
SQL Server MVP
"marcmc" <marcmc@.discussions.microsoft.com> wrote in message
news:E68737B1-89BA-4915-A1F0-EF816A91DF05@.microsoft.com...
> Thx
> So you can't get them in SQL? How then does it know ehen they are
> exceeded?
>
> "Dan Guzman" wrote:
>|||Keep in mind that underneath SQL's engine is a simple check that detemrines
whether the numeric data it is trying to store is larger than the byte thres
hold
(Integer=4, SmallInt=2, TinyInt=1). It's not "storing" the maximum decimal v
alue
per se. You just have to know that the range of an integer is 2^31 to 2^31-1
.
Thomas
"marcmc" <marcmc@.discussions.microsoft.com> wrote in message
news:E68737B1-89BA-4915-A1F0-EF816A91DF05@.microsoft.com...
> Thx
> So you can't get them in SQL? How then does it know ehen they are exceeded
?
>
> "Dan Guzman" wrote:
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment