In a professional situation, an incorrectly selected record can result in a mortifying loss of data. Therefore, it behooves one to select the proper row carefully in one's stored procedure. That's why Charles's development team uses SearchGuard, the premier design pattern for selecting just the right row:


DELETE FROM [dbo].[tbl_employee] WHERE ((
	[employee_id] = @Original_employee_id) 
	AND ([salesperson_flag] = @Original_salesperson_flag) 
	AND ([first_name] = @Original_first_name) 
	AND ([last_name] = @Original_last_name) 
	AND ((@IsNull_job_title_type_id = 1 
	AND [job_title_type_id] IS NULL) OR ([job_title_type_id] = @Original_job_title_type_id)) 
	AND ((@IsNull_address_id = 1 AND [address_id] IS NULL) OR ([address_id] = @Original_address_id)) 
	AND ((@IsNull_work_extension = 1 AND [work_extension] IS NULL) OR ([work_extension] = @Original_work_extension)) 
	AND ((@IsNull_home_phone_number = 1 AND [home_phone_number] IS NULL) OR ([home_phone_number] = @Original_home_phone_number)) 
	AND ((@IsNull_alternate_phone_number = 1 AND [alternate_phone_number] IS NULL) OR ([alternate_phone_number] = @Original_alternate_phone_number)) 
	AND ((@IsNull_relative_name = 1 AND [relative_name] IS NULL) OR ([relative_name] = @Original_relative_name)) 
	AND ((@IsNull_relative_phone_number = 1 AND [relative_phone_number] IS NULL) OR ([relative_phone_number] = @Original_relative_phone_number)) 
	AND ((@IsNull_hire_date = 1 AND [hire_date] IS NULL) OR ([hire_date] = @Original_hire_date)) 
	AND ((@IsNull_termination_date = 1 AND [termination_date] IS NULL) OR ([termination_date] = @Original_termination_date)) 
	AND ((@IsNull_team_type_id = 1 AND [team_type_id] IS NULL) OR ([team_type_id] = @Original_team_type_id)) 
	AND ((@IsNull_comment = 1 AND [comment] IS NULL) OR ([comment] = @Original_comment)) 
	AND ((@IsNull_social_security_number = 1 AND [social_security_number] IS NULL) OR ([social_security_number] = @Original_social_security_number)) 
	AND ((@IsNull_drivers_license_number = 1 AND [drivers_license_number] IS NULL) OR ([drivers_license_number] = @Original_drivers_license_number)) 
	AND ((@IsNull_badge_number = 1 AND [badge_number] IS NULL) OR ([badge_number] = @Original_badge_number)) 
	AND ((@IsNull_hourly_wages = 1 AND [hourly_wages] IS NULL) OR ([hourly_wages] = @Original_hourly_wages)) 
	AND ((@IsNull_w2_claim = 1 AND [w2_claim] IS NULL) OR ([w2_claim] = @Original_w2_claim)) 
	AND ((@IsNull_insurance_start_date = 1 AND [insurance_start_date] IS NULL) OR ([insurance_start_date] = @Original_insurance_start_date)) 
	AND ((@IsNull_date_of_birth = 1 AND [date_of_birth] IS NULL) OR ([date_of_birth] = @Original_date_of_birth)) 
	AND ((@IsNull_shirt_size_type_id = 1 AND [shirt_size_type_id] IS NULL) OR ([shirt_size_type_id] = @Original_shirt_size_type_id)) 
	AND ([active_flag] = @Original_active_flag) AND ([network_userid] = @Original_network_userid) 
	AND ((@IsNull_vacation_days = 1 AND [vacation_days] IS NULL) OR ([vacation_days] = @Original_vacation_days)) 
	AND ((@IsNull_sick_days = 1 AND [sick_days] IS NULL) OR ([sick_days] = @Original_sick_days)) 
	AND ((@IsNull_last_vacation_update = 1 AND [last_vacation_update] IS NULL) OR ([last_vacation_update] = @Original_last_vacation_update)) 
	AND ([part_time_flag] = @Original_part_time_flag) 
	AND ((@IsNull_part_time_hours = 1 AND [part_time_hours] IS NULL) OR ([part_time_hours] = @Original_part_time_hours)) 
	AND ([first_eligible_bonus_received] = @Original_first_eligible_bonus_received) AND ((@IsNull_first_eligible_bonus_received_date = 1 AND [first_eligible_bonus_received_date] IS NULL) OR ([first_eligible_bonus_received_date] = @Original_first_eligible_bonus_received_date)) 
	AND ([awa_location_id] = @Original_awa_location_id) 
	AND ([rowguid] = @Original_rowguid) 
	AND ((@IsNull_bonus_view_date = 1 AND [bonus_view_date] IS NULL) OR ([bonus_view_date] = @Original_bonus_view_date)) 
	AND ((@IsNull_ceiva_flag = 1 AND [ceiva_flag] IS NULL) OR ([ceiva_flag] = @Original_ceiva_flag)) 
	AND ([ethnicity_id] = @Original_ethnicity_id) 
	AND ((@IsNull_sex = 1 AND [sex] IS NULL) OR ([sex] = @Original_sex)))

Its powerful protection reduces the risk of false positives to practically zero, and with a plethora of fields to match on, it's virtually impossible to delete the wrong row.

SearchGuard: Anything less would be uncivilized.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!