Filter SQL result using XML

Filter SQL result using XML

I have created the following piece of code to ensure that I can filter certain dimension using a comma delimited parameter:

I have created the following piece of code to ensure that I can filter certain dimension using a comma delimited parameter:

DECLARE @Dimension NVARCHAR(MAX)

SET @Dimension = 'Average Life,Coupon Frequency'

DECLARE @XML XML SET @XML = CAST('<i>' + REPLACE(@Dimension, ',', '</i><i>') + '</i>' AS XML)

SELECT d.* FROM Dim_Security_Analytics as d

INNER JOIN @XML.nodes('i') x(i) ON d.dimension = x.i.value('.', 'NVARCHAR(MAX)')

WHERE d.Date = '2018-12-31'

However when a '' or a NULL is passed in the @Dimension parameter I would like all dimensions to be returned. I'm unsure as to how I can code for this in the XML as this is pretty new to me.

Can anyone point me in the right direction?

Thanks

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

What are the differences between Standard SQL and Transact-SQL?

In this article, we'll explain syntax differences between standard SQL and the Transact-SQL language dedicated to interacting with the SQL

Sum Time columns in SQL

I'm writing a query to calculate when the students check-in and check-out and how much time they spend at the GYM. I have a Checking Field that contains the check-in time and a check-out field that contains the check-out, and a Duration.

T-SQL Training using Real World Scenarios:Tricks of the Trade | Simpliv

T-SQL Training using Real World Scenarios:Tricks of the Trade