2
Reply

sql query to delete and return message

Develop Shailendra

Develop Shailendra

Nov 10 2016 5:07 AM
210

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)