Created
August 4, 2015 23:18
-
-
Save jvrck/dd378cb69cb4366d915e to your computer and use it in GitHub Desktop.
SQL Optional Parameters (SQL Server)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| source: http://stackoverflow.com/questions/11092576/sql-query-with-optional-parameter-and-possible-null-column | |
| Add optinal parameters to SQL scripts or sps | |
| */ | |
| select id, customername | |
| from customertable | |
| where | |
| (referredby = @referredby OR @referredby is null) and | |
| (field2 = @f2 OR @f2 is null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment