Question: Knowing I have 2 variables declared called @Variable and @Name, I need something like this:

```
SELECT * from (myDbTable)
CASE WHEN (@Variable IS NOT NULL AND @Variable <> '')
THEN WHERE myDbTable.variable LIKE @Variable
ELSE WHERE myDbTable.name LIKE @Name

```

Basically, if the user enters a "variable" value, it should do a WHERE-clause on that variable, if not, it should do a WHERE-clause on Name.

Can I do this in SQL?

Answer: 
There is an `/EXCLUDE` option of [`xcopy`](https://ss64.com/nt/xcopy.html "XCOPY"), which allows to specify (the path to) a text file that contains partial file paths/names one per line (note also the fixed quotation):

```cmd
xcopy /S /Y /R /I /EXCLUDE:exclude.txt "C:\SourceCodeOld\Release\Source Code\*.vb" "C:\SourceCodeNew\Source Code"

```

with `exclude.txt` being in the current working directory and containing:

```cmd
AssemblyInfo.vb

```

However, the implementation of the `/EXCLUDE` option is terrible, because actually *all* files are excluded whose absolute source paths contain any of the given strings at *any* position (in a case-insensitive manner). Moreover, you cannot even use [wildcards](https://ss64.com/nt/syntax-wildcards.html "How-to: Match filenames with Wildcards") in these strings. Furthermore, you cannot provide a quoted path to the exclusion text file to protect potential spaces or special characters. (Refer also to [this related answer of mine](https://stackoverflow.com/a/42399461 "Exclude multiple file extension in xcopy").)

---

I strongly recommend to use the [`robocopy` command](https://ss64.com/nt/robocopy.html "ROBOCOPY"), whose exclusion options are more mature:

```cmd
robocopy "C:\SourceCodeOld\Release\Source Code" "C:\SourceCodeNew\Source Code" "*.vb" /S /XF "AssemblyInfo.vb"

```

This truly excludes only files whose names are `AssemblyInfo.vb`.
Create a file `excludes.txt` and add the files to exclude to it (each in a new line)

```
AssemblyInfo.vb
anotherfile.vb

```

Then run your `xcopy` command using the `/EXCLUDE` parameter pointing to the file that contains the files to exclude:

```
xcopy "C:\SourceCodeOld\Release\Source Code\*.vb" "C:\SourceCodeNew\Source Code\" /EXCLUDE:excludes.txt /S /Y /R

```

To see the various options available for the `/EXCLUDE` parameter, run `xcopy /?`