TSQL two Select command one single table output?

If (select count(1) from tblPages where bitActive = 1) > 0 begin select * from tblPages where bitActive = 1 end else begin select * from tblPages where bitActive = 0 end.

I would use if exists(select * from ... instead of count because it could stop the query when it finds one row that matches the where condition. But your query, when comparing against > 0, has the exact same execution plan as the exists version. The query optimizer is smart enough (SQL Server 2008) to realize that you don't actually need to count all rows.

– Mikael Eriksson Nov 16 at 4:57 thanks, solved! – Nazo Tajrian Nov 17 at 2:51 please mark this as the accepted answer (the check mark to the left of my post) thanks – Derek Kromm Nov 17 at 3:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions