Search code examples
sqlsql-server-2008sql-variant

Get the non empty data from a sql_varient column


I have a sql table with sql_varient column. I want to query the table to get the records which has value. I used following query

SELECT *
from Table
WHERE sql_varient_column IS NOT NULL

But its return the data which has no data also. How can I achieve this


Solution

  • To get the row for column sql_varient_column is not null and not empty:

    SELECT *
    from Table
    WHERE NULLIF(sql_varient_column, '') IS NOT NULL