Skip to content
Advertisement

Conditional query with a parameter stored procedure

I’m learning SQL so I don’t know yet all the subtlety of the language,

I wrote the following stored procedure (simplified here):

But it doesn’t look like a natural way to do that and there is a lot of repeated code.

I want to avoid something like

But if it’s the only way.

I don’t know the correct tag but sqllocaldb info MSSQLLocalDB return

Version : 13.1.4001.0

and I use SQL Server Management Studio (SSMS)

Advertisement

Answer

Just:

The where clause can be simplified:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement