Quantcast
Channel: functions – SQL Server Rider
Viewing all articles
Browse latest Browse all 13

Type_ID and Type_Name – SQL Server

$
0
0

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.

 



Viewing all articles
Browse latest Browse all 13

Trending Articles