Question

I created an SCCM SQL report using SQL Management Studio. I then created the following prompts for my Asset Management Office to use on the web report: Publisher, Display Name, and Version.

The Display Name and the Version prompts are both optional.

I receive no syntax errors or anything, but I receive absolutely no results whatsoever when I click on the Display button to produce the web report.

Here is my SQL code:

==================================================================================

SELECT dbo.v_R_System.Netbios_Name0, dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0

FROM dbo.v_R_System INNER JOIN dbo.v_GS_ADD_REMOVE_PROGRAMS ON dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID

WHERE dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 = @DisplayName AND dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 = @Version AND dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 = @Publisher

Order by dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 ASC

==================================================================================

I run my report and in the Publisher prompt, I type in something like %Autodesk% and then I click the Display button, and absolutely nothing is displayed. I can go to another report and look up Autodesk products, but not this one. I am not a well versed SQL guy, so if anyone can help me that would be great.

Thanks

Was it helpful?

Solution

% signs often mean wildcards. They are used with the like keyword. You have equal signs. In other words,

where DisplayName like '%fred%'

will return fred, freddie, frederick, etc. However,

where DisplayName = '%fred%'

will only return %fred%

OTHER TIPS

AHHHH I see what you were talking about Dan.

Disregard my last statement/inquiry everyone, I got my code working now. My Prompt @variables' SQL code was not configured properly to work with the "Like" constant so I modified my main SQL code to be this:

================================================================================== Select Distinct dbo.v_R_System.Netbios_Name0, dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 FROM dbo.v_R_System Join dbo.v_GS_ADD_REMOVE_PROGRAMS On dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID Where dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 Like @Publisher Or dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 Like @DisplayName Or dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 Like @VersionOrder by dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 ASC

==================================================================================

Then I had to modify my Prompt SQL code to use the Begin, If, Else, and End statements. I will pick just my @Publisher variable Prompt SQL code since all of my Prompt @variables' SQL code are basically identical.

Here is the SQL code for my Publisher (@Publisher) Prompt:

==================================================================================

Begin
If(@__filterwildcard = '')
Select Distinct Publisher0
From v_Add_Remove_Programs Order By Publisher0
Else
Select Distinct Publisher0 From v_Add_Remove_Programs
Where Publisher0 Like @__filterwildcard
Order By Publisher0
End

==================================================================================

The code I used before for my Prompt @variables was like this which did not work with the "Like" constant in my main SQL code:

==================================================================================

Select Distinct Publisher0
From v_Add_Remove_Programs Order By Publisher0 Where Publisher0 Like @__filterwildcard
Order By Publisher0

==================================================================================

So, apparently using the Begin, If, Else, and End statements allowed for more logic in this query process, therefore allowing me to use the "Like" constant in my main SQL code for the report.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top