I have a single int output parameter for a sproc in MSSQL 2008. The value can be null or it can be populated.
I am trying to write a clever single select statement that will return one row:
if the param value is populated, return that row
if the param value is null, return the top 1 row where issoftdeleted=0
Thanks for all ideas.
If you expect one row when @param is set then use TOP (1)
Personally, I’d consider using an IF statement and 2 separate SELECTs…