sql server - return a default record from a sql query -


i have sql query run against sql server database eg.

select * mytable id = 2 

this may return number of records or may return none. if returns none, alter sql query return default record, possible , if so, how? if records returned, default record should not returned. cannot update data need alter sql query this.

another way (you empty initial rowset returned);

select * mytable id = 2 if (@@rowcount = 0)    select ... 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -

delphi - How to convert bitmaps to video? -