2
Answers

sql query to delete and return message

I want to write some thing like that query.

BEGIN

DECLARE @Unaloacte int;
DECLARE @Total int;
DECLARE @Flag int;

 SET @Unaloacte =( Select count(PD.PropertyDetailId)
      from PropertyDetail AS PD join SiteDetail AS SD ON PD.SiteDetailId=SD.SiteDetailId
      Where PD.CustomerId<1 and PD.SiteDetailId=27);

 SET @Total= (Select count(PropertyDetailId) as Total_Count from PropertyDetail
    where SiteDetailId=27) ;

if( @Unaloacte = @Total)

    Delete something and display message print"Delete";

 else

print"Not able to delete"
END

I hope you understand my problem.......!!!

Answers (2)