Thanks a lots....Mr gvprabu sir, You gave the solution in deletion with two tables.... Same problem are coming in Updation the store procedure are write this----
--------
I am new on Sql Server2008 r2 how can update records in two tables with head =true or false condition ???
ALTER PROCEDURE [dbo].[spUpdateParivarRegister]
(
@HouseNo nvarchar(50),
@StateID int,
@DistrictID int,
@WardID int,
@MohallaID int,
@FamilyMemberID int,
@RegistrationStatus Int OUTPUT,
@ActiveHead bit,
@MemberName nvarchar(50),
@FatherHusbandName nvarchar(50),
@RegistrationDate Datetime,
@DateOfBirth Datetime,
@Age int,
@TotalMember int,
@MobileNo NVarchar(50),
@SexID int,
@MaritalStatusID int,
@QualificationID int,
@OccupationID int,
@ReligionID int,
@CardId INT,
@CardNo Nchar(12),
@PhotoName nvarchar(50),
@PhotoImagePath nvarchar(2000),
@GISID nvarchar(50),
@Language int
)
AS
BEGIN
Begin Try
Begin Tran Tran1
SET @RegistrationStatus = -1
declare @Family int
BEGIN
UPDATE FamilyHead
SET HouseNo = @HouseNo
,StateID = @StateID
,DistrictID = @DistrictID
,WardID = @WardID
,MohallaID = @MohallaID
FROM FamilyMember FM
left outer Join FamilyHead FH on FM.FamilyID =FH.FamilyID
if(@ActiveHead=1)
BEGIN
UPDATE FamilyHead SET FamilyHeadName=@MemberName WHERE FamilyID=@Family
END
UPDATE FamilyMember
SET MemberName =@MemberName
,PhotoName=@PhotoName
,PhotoImagePath=@PhotoImagePath
,FatherHusbandName= @FatherHusbandName
,RegistrationDate=@RegistrationDate
,DateOfBirth=@DateOfBirth
,Age=@Age
,TotalMember=@TotalMember
,MobileNo=@MobileNo
,SexID=@SexID
,MaritalStatusID=@MaritalStatusID
,QualificationID=@QualificationID
,OccupationID=@OccupationID
,ReligionID=@ReligionID
,CardId=@CardId
,CardNo=@CardNo
,GISID=@GISID
,Language=@Language
WHERE FamilyMemberID=@FamilyMemberID
SET @RegistrationStatus = 1
COMMIT TRAN Tran1
END
END TRY
BEGIN CATCH
print'Exception Here'
SET @RegistrationStatus = 2
ROLLBACK TRAN Tran1
END CATCH
END