Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If query returns < 3 results, run new query

Status
Not open for further replies.

lynque

IS-IT--Management
Sep 30, 2004
124
CA
Hello all,

I'm running a web app in C# .NET and am trying to backfill my query by re-querying the DB if it returns less than three results. This is probably not a hard one but I don't know where to begin.

Any tips are appreciated
 
Sounds like a C# question....

forum732

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
 
If you're running a stored procedure , you could do as part of your stored procedure:
SET NOCOUNT ON;
declare @cnt INT
SET @cnt = (SELECT COUNT (*) FROM myTable )

IF @cnt > 3
BEGIN
SELECT COUNT (*) FROM myTable
END
ELSE
<whatever the second sql statement would be>
END

All the IT jobs in one place -
 
Thanks JackVam,
That's exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top