Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 SSDT - Edit data - IS NULL not work as filter

I am trying to filter some row of a table with ssdt (left click on table, view data, sort and filter)

Here I simply need to add IS NULL as a condition to an nvarchar field.
But as soon as I apply filter I get the error:

Incorrect syntax near the keyword SET

Looking at the query written by editor I see that the consition is fldName =, no sign of my NULL check

How can I do it?

This is th result:

SELECT TOP 1000 [Ktyi_TS002_IdTipoDocumento] ,
[nvc_TS002_TipoDocumento] ,[nvc_TS002_IdFunzioneControllo] ,[bit_TS002_Annullato] 
FROM [dbo].[TS002_TipoDocumento] 
WHERE [nvc_TS002_IdFunzioneControllo] =

this is some images of the data editor found in google to show what iam talking about to who don't know ssdt:

enter image description here

enter image description here

like image 837
gt.guybrush Avatar asked Aug 27 '15 15:08

gt.guybrush


2 Answers

It seems to be a bug that IS (NOT) NULL expression is not supported in the filter.

like image 155
Eric Kang Avatar answered Nov 14 '22 22:11

Eric Kang


This is a very ugly hack, but it may work for you.

It seems like you need a column name on the left of the = sign to keep the filter parser from changing the query. In my case my column that I was looking for nulls in was an integer, so I needed to get an integer on the left hand side.

I also needed a value for the columns that I was looking for nulls in that would not exist for any non-null row. In my case this was 0.

Create MyTable 
(  Id    int primary key,
     ...
   MyNum  int
);

To search for rows with nulls in column MyNum, I did this:

[Id] - [Id] = IsNull([MyNum],0)

The [Id] - [Id] was used to produce 0 and not trigger the parser to re-write the statement as [MyNum] = stuff

The right hand side was not re-written by the parser so the NULL values were changed to 0's.

I assume for strings you could do something similar, maybe

concatenate([OtherStringCol],'XYZZY') = ISNull([MyStrCol],concatenate([OtherStringCol],'XYZZY'))

The 'XYZZY' part is used to ensure that you don't get cases where [MyStrCol] = [OtherStringCol]. I am assuming that the string 'XYZZY' doesn't exist in these columns.

like image 21
Mike Wodarczyk Avatar answered Nov 14 '22 21:11

Mike Wodarczyk