--CREATE PROCEDURE sp_test AS SELECT 1 WHERE RAND()>=0.5
GO
EXEC sp_test
IF @@ROWCOUNT=0 PRINT 'DO SOMETHING' ELSE PRINT 'SOMETHING ELSE'
GO
It sill returns the resultset. If it returns many rows I would change or would create another SP. Sometimes especially if unexperienced with Transact SQL, it's best to give more détails about the actual need so that one can suggest what could be done when
starting from 0.
Here this is a minimal amount assuming for example you can't change the SP at all and need to reuse it (and you don't need what it returns ?)
Member
504 Points
1776 Posts
Query
Nov 14, 2018 05:26 AM|JagjitSingh|LINK
Hi
I want if query return records using Stored procedure then perform some calculation else perform some other calculation
Thanks
All-Star
48570 Points
18082 Posts
Re: Query
Nov 14, 2018 09:41 AM|PatriceSc|LINK
Hi,
What do you get from your SP ? You could use maybe : https://docs.microsoft.com/en-us/sql/t-sql/functions/rowcount-transact-sql?view=sql-server-2017
It sill returns the resultset. If it returns many rows I would change or would create another SP. Sometimes especially if unexperienced with Transact SQL, it's best to give more détails about the actual need so that one can suggest what could be done when starting from 0.
Here this is a minimal amount assuming for example you can't change the SP at all and need to reuse it (and you don't need what it returns ?)