Return to Snippet

Revision: 9413
at November 4, 2008 15:07 by hoffstein


Initial Code
Data types listed above.

Initial URL
http://www.teratrax.com/sql_guide/data_types/sql_server_data_types.html

Initial Description
## Exact numerics

<table>
  <tr>
    <td>
      <b>Type </b>
    </td>
    
    <td>
      <b>From </b>
    </td>
    
    <td>
      <b>To </b>
    </td>
  </tr>
  
  <tr>
    <td>
      bigint 
    </td>
    
    <td>
      -9,223,372,036,854,775,808 
    </td>
    
    <td>
      9,223,372,036,854,775,807 
    </td>
  </tr>
  
  <tr>
    <td>
      int 
    </td>
    
    <td>
      -2,147,483,648 
    </td>
    
    <td>
      2,147,483,647 
    </td>
  </tr>
  
  <tr>
    <td>
      smallint 
    </td>
    
    <td>
      -32,768 
    </td>
    
    <td>
      32,767 
    </td>
  </tr>
  
  <tr>
    <td>
      tinyint 
    </td>
    
    <td>
    </td>
    
    <td>
      255 
    </td>
  </tr>
  
  <tr>
    <td>
      bit 
    </td>
    
    <td>
    </td>
    
    <td>
      1 
    </td>
  </tr>
  
  <tr>
    <td>
      decimal 
    </td>
    
    <td>
      -10^38 +1 
    </td>
    
    <td>
      10^38 –1 
    </td>
  </tr>
  
  <tr>
    <td>
      numeric 
    </td>
    
    <td>
      -10^38 +1 
    </td>
    
    <td>
      10^38 –1 
    </td>
  </tr>
  
  <tr>
    <td>
      money 
    </td>
    
    <td>
      -922,337,203,685,477.5808 
    </td>
    
    <td>
      +922,337,203,685,477.5807 
    </td>
  </tr>
  
  <tr>
    <td>
      smallmoney 
    </td>
    
    <td>
      -214,748.3648 
    </td>
    
    <td>
      +214,748.3647 
    </td>
  </tr>
</table>

numeric<span> and </span> decimal<span> are Fixed precision and scale data types and are functionally equivalent.</span>
## Approximate numerics

<table>
  <tr>
    <td>
      <b>Type</b>
    </td>
    
    <td>
      <b>From</b>
    </td>
    
    <td>
      <b>To</b>
    </td>
  </tr>
  
  <tr>
    <td>
      float
    </td>
    
    <td>
      -1.79E + 308
    </td>
    
    <td>
      1.79E + 308
    </td>
  </tr>
  
  <tr>
    <td>
      real
    </td>
    
    <td>
      -3.40E + 38
    </td>
    
    <td>
      3.40E + 38
    </td>
  </tr>
</table>

 

## datetime and smalldatetime

<table>
  <tr>
    <td>
      <b>Type</b>
    </td>
    
    <td>
      <b> From</b>
    </td>
    
    <td>
      <b>To</b>
    </td>
  </tr>
  
  <tr>
    <td>
      datetime (3.33 milliseconds accuracy)
    </td>
    
    <td>
      Jan 1, 1753
    </td>
    
    <td>
      Dec 31, 9999
    </td>
  </tr>
  
  <tr>
    <td>
      smalldatetime (1 minute accuracy)
    </td>
    
    <td>
      Jan 1, 1900
    </td>
    
    <td>
      Jun 6, 2079
    </td>
  </tr>
</table>

 
## Character Strings

<table>
  <tr>
    <td>
      <b>Type</b>
    </td>
    
    <td>
      <b>Description</b>
    </td>
  </tr>
  
  <tr>
    <td>
      char
    </td>
    
    <td>
      Fixed-length non-Unicode character data with a maximum length of 8,000 characters.
    </td>
  </tr>
  
  <tr>
    <td>
      varchar
    </td>
    
    <td>
      Variable-length non-Unicode data with a maximum of 8,000 characters.
    </td>
  </tr>
  
  <tr>
    <td>
      varchar(max)
    </td>
    
    <td>
      Variable-length non-Unicode data with a maximum length of 2<sup>31</sup> characters (<b>SQL Server 2005 only</b>).
    </td>
  </tr>
  
  <tr>
    <td>
      text
    </td>
    
    <td>
      Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters.
    </td>
  </tr>
</table>

 
## Unicode Character Strings

<table>
  <tr>
    <td>
      <b>Type</b>
    </td>
    
    <td>
      <b>Description</b>
    </td>
  </tr>
  
  <tr>
    <td>
      nchar
    </td>
    
    <td>
      Fixed-length Unicode data with a maximum length of 4,000 characters.
    </td>
  </tr>
  
  <tr>
    <td>
      nvarchar
    </td>
    
    <td>
      Variable-length Unicode data with a maximum length of 4,000 characters.
    </td>
  </tr>
  
  <tr>
    <td>
      nvarchar(max)
    </td>
    
    <td>
      Variable-length Unicode data with a maximum length of 2<sup>30</sup> characters (<b>SQL Server 2005 only</b>).
    </td>
  </tr>
  
  <tr>
    <td>
      ntext
    </td>
    
    <td>
      Variable-length Unicode data with a maximum length of 1,073,741,823 characters.
    </td>
  </tr>
</table>

 
## Binary Strings


<table>
  <tr>
    <td>
      <b>Type</b>
    </td>
    
    <td>
      <b>Description</b>
    </td>
  </tr>
  
  <tr>
    <td>
      binary
    </td>
    
    <td>
      Fixed-length binary data with a maximum length of 8,000 bytes.
    </td>
  </tr>
  
  <tr>
    <td>
      varbinary
    </td>
    
    <td>
      Variable-length binary data with a maximum length of 8,000 bytes.
    </td>
  </tr>
  
  <tr>
    <td>
      varbinary(max)
    </td>
    
    <td>
      Variable-length binary data with a maximum length of 2<sup>31</sup> bytes (<b>SQL Server 2005 only</b>).
    </td>
  </tr>
  
  <tr>
    <td>
      image
    </td>
    
    <td>
      Variable-length binary data with a maximum length of 2,147,483,647 bytes.
    </td>
  </tr>
</table>

Initial Title
SQL Server 2005 data types

Initial Tags

                                

Initial Language
Other