How can I get the max value of SqlDbTypes like max SqlDbType.Int?

1.9k Views Asked by At

I would like to assign some string typed variables to MAximum values of some types in SQL Server 2008.

For example:

string foo = MaxValueInDbFor(SqlDbType.Int);
string boo = MaxValueInDbFor(SqlDbType.SmallInt);

How can I achieve this? Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

If I understand correctly you need this.

var maxValue =  System.Data.SqlTypes.SqlInt16.MaxValue;
var minValue =  System.Data.SqlTypes.SqlInt16.MinValue;

Same way you can get Sql***.MaxValue or Sql***.MinValue properties for any sql types .

Check out System.Data.SqlTypes namespace for more info.