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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make SP return only 1 table

Status
Not open for further replies.

rico14d

Programmer
Apr 8, 2002
135
GB
Hi,

Is there anyway i can clear what is returned from a stored procedure?

Basically i only want to only return 1 table from the example below, instead of 1 empty table then a table of results.

select * from Product where name = 'test'

if @@RowCount = 0
begin
-- I would want to 'clear' what has already been returned above here.
select * from Product where name like '%test%'
end

Thanks,
Rich
 
Code:
SET NOCOUNT ON

IF NOT EXISTS(SELECT * FROM Product WHERE Name = 'test')
   begin
      SELECT * FROM Product WHERE Name LIKE '%test%'
   end
ELSE
   begin
       SELECT * FROM Product WHERE Name = 'test'
   end

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Borislav,

That would work for the example above, but my scenario is much more complicated than that.

For your example i have to repeat the initial query in code twice, i really wanted something cleaner that could just remove the contents of the buffer.

Thanks for your help,
Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top