Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent data type for SQL_Variant in sql server not found in postgresql

I cannot find any equivalent datatype for SQL_Variant in potgresql. Sql_variant is available in sql server. I am new to postgres and presently migrating from sql server to postgres.

like image 475
Sayan Majumder Avatar asked Aug 31 '25 16:08

Sayan Majumder


2 Answers

There is no such data type in PostgreSQL.

You can either use several attributes, one for each possible type (and maybe a CHECK constraint that assures that exactly one of them is NOT NULL) or store binary data (type bytea) and convert them to whatever data type you need in the application.

like image 139
Laurenz Albe Avatar answered Sep 02 '25 13:09

Laurenz Albe


Here is about sql_variant link sql_variant (Transact-SQL)

I would say the closest you could get is to declare a text column and store the string representations of the values.

like image 28
Джирайя Avatar answered Sep 02 '25 13:09

Джирайя