NULL vs Empty String for Literal Inputs

edited May 5 in QueryViews

Let's assume we define a Literal Input for customer as follows:

This will allow us to use {{customer}} as a parameter in our queries.

We can now write a query as:

EXEC dbo.Test_sp @Param1 = {{customer}}

This will translate to:

EXEC dbo.Test_sp @Param1 = '<user defined value>'


So, for example, on the View page of the QueryView, you will see this input field:

if you put in foo, your query will be set to:

EXEC dbo.Test_sp @Param1 = 'foo'

if you leave the input blank, your query will be set to:

EXEC dbo.Test_sp @Param1 = ''


Now, in some cases, you may want to have NULL rather than an empty string. For that, use <NULL> as the default value in the Literal Input settings.

In this case, if the user-defined value is left blank, the query will be set as:

EXEC dbo.Test_sp @Param1 = NULL

Sign In or Register to comment.