Home > SQL Server > Type_ID and Type_Name – SQL Server

Type_ID and Type_Name – SQL Server


Type_ID() : This function returns the SQL Sever data type id for the given type name. You can refer my previous blog post for the data type list. This function returns an integer value for type id. We should pass a valid argument type name string with or without schema name. This function may return null value if the type string is invalid or we do not have permission to access the object.

Function Syntax

TYPE_ID ( [ schema_name ] type_name )

Example

Executing type_id function with a valid argument

pic1Type_Name() : This function returns the valid data type name for a valid type id argument. This function returns a sysname type value.  This function may return null value if the type string is invalid or we do not have permission to access the object. This function argument type is integer.

Function Syntax

TYPE_NAME ( type_id )

Example

Executing type_name function with valid type id. We can also use Type_ID function in this function argument.

pic2To list all SQL Server type information using catalog view (sys.types).

select * from sys.types

Execute this query in SSMS to get the list of SQL Server type information.

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: