Click here to Skip to main content
12,403,944 members (72,180 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked

Data Type Synonyms

, 14 Mar 2010 CPOL
Rate this:
Please Sign up or sign in to vote.


This article basically illustrates the concept of Data type synonyms which are included in SQL Server 2005 for SQL-92 compatibility.

What are Data Type Synonyms?

Data type synonyms can be used instead of the corresponding base data type name in data definition language (DDL) statements, such as CREATE TABLE, CREATE PROCEDURE, or DECLARE @variable. However, after the object is created, the synonyms have no visibility. When the object is created, the object is assigned the base data type that is associated with the synonym. There is no record that the synonym was specified in the statement that created the object.

All objects that are derived from the original object, such as result set columns or expressions, are assigned the base data type. All subsequent metadata functions performed on the original object and any derived objects will report the base data type, not the synonym. This behavior occurs with metadata operations, such as sp_help and other system stored procedures, the information schema views, or the various data access API metadata operations that report the data types of table or result set columns.

List of Data Type Synonyms  

Synonym SQL Server system data type
Binary varying varbinary
char varying  varchar
character char
character char(1)
character(n) char(n)
character varying(n) varchar(n)
Dec decimal
Double precision float
float[(n)] for n = 1-7 real
float[(n)] for n = 8-15 float
integer int
national character( n ) nchar(n)
national char( n ) nchar(n)
national character varying( n ) nvarchar(n)
national char varying( n ) nvarchar(n)
national text ntext
rowversion timestamp

How to use Data Type Synonyms 

For example, you can create a table by specifying Data Type Synonyms:

FirstName character varying(20),
LastName national character varying(20),
Marks Double precision)

FirstName is actually assigned an varchar(20) data type, and all subsequent metadata functions will report the column as an varchar(20) column. The metadata functions will never report them as a character varying(20) column.
Similarly, LastName is an nvarchar(20) data type column and Makes is a float column.


This is an introduction to the Data Type Synonyms in SQL Server. The idea is to get familiar with another way of writing DDL queries using Data Type Synonyms.




This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sumit Garg From Chandigarh
Technical Lead AuthorGen Technologies
India India
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 14 Mar 2010
Article Copyright 2010 by Sumit Garg From Chandigarh
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid