Hi I'm relatively new to SQL. I'm trying to create a stored procedure to take a count of recrods with some criteria. If the count <> 1 then I want it to Print a value so that I can pass it back to my application in
select sum(clientid) as NumClients
where clientid = '1709'
if NumClients <> 1
Do something like this:
CREATE PROCEDURE [dbo].[usp_EmpCheck] ( @ClientID INT, @App VARCHAR(50), @CheckResult BIT OUTPUT ) AS BEGIN IF ( SELECT SUM(clientid) FROM TblEmployee WHERE clientid = @ClientID AND ApplicationID = @CheckResult ) <> 1 BEGIN SET @CheckResult = 1 END ELSE BEGIN SET @CheckResult = 0 END END
Then get your VB to act on the value of the procedure OUTPUT parameter.