Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Posting below Stored Procedure
In this first I am trying to find a record in a client DB if not found there
searching it in Master DB.
Using stored procedure in a ASP application.

Pls help in getting return values without any output parameter

SQL
ALTER PROCEDURE [dbo].[app_AuthenticateEmailCount]
    @Email varchar(50)

AS
BEGIN
DECLARE @TotalCRecords varchar(10);
DECLARE @TotalMRecords varchar(10)


set @TotalCRecords = 'SELECT COUNT(*) AS TotalCRecords FROM ff_fvdcbdev.dbo.app_User cu inner join ff_fvdcbdev.dbo.app_Person cp on cu.idUser = cp.idUser
    WHERE cp.emailAddress =' + @Email


    IF (@TotalCRecords = '0')
    set @TotalMRecords = 'SELECT COUNT(*) AS TotalMRecords FROM freefunds.dbo.app_User mu inner join freefunds.dbo.app_Person mp on mu.idUser = mp.idUser
    WHERE mp.emailAddress =' + @Email
Posted
Updated 13-Sep-15 22:00pm
v2

1 solution

Try UNION :
SQL
SELECT 'CRecords' as [Type], COUNT(*) AS [Count] FROM ff_fvdcbdev.dbo.app_User cu inner join ff_fvdcbdev.dbo.app_Person cp on cu.idUser = cp.idUser
    WHERE cp.emailAddress = @Email
UNION 
SELECT 'MRecords' as [Type], COUNT(*) AS [Count] FROM freefunds.dbo.app_User mu inner join freefunds.dbo.app_Person mp on mu.idUser = mp.idUser
    WHERE mp.emailAddress = @Email
 
Share this answer
 
Comments
vivekloffa 14-Sep-15 6:25am    
Thanks!
Maciej Los 14-Sep-15 14:59pm    
5ed!
Mehdi Gholam 15-Sep-15 2:42am    
Cheers Maciej!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900