I have a stored Procedure
CREATE PROCEDURE DeleteDataByUserID
@UserID int
as
BEGIN
delete from staffskills where StaffProfileID=(select s.StaffProfileID from staffprofiles s where s.userid=@UserID)
delete from staffLanguages where StaffProfileID=(select s.StaffProfileID from staffprofiles s where s.userid=@UserID)
delete from staffLocations where StaffProfileID=(select s.StaffProfileID from staffprofiles s where s.userid=@UserID)
END
Now I want Code Like
CREATE PROCEDURE DeleteDataByUserID
@UserID int
as
BEGIN
int staffID=select s.StaffProfileID from staffprofiles s where s.userid=@UserID
delete from staffskills where StaffProfileID=staffID
delete from staffLanguages where StaffProfileID=staffID
delete from staffLocations where StaffProfileID=staffID
END
In case of first one for every statement i am going to db and fetching staffid everytime.
How to over come this one .