I have a very large sql table that I need to build a manual update command for.
In visual studio, when you use a data adapter in the designer to create the update command based off of your select command, you get extra parameters for Null checking, and also comparing the original values.
(command shortened for example)
I have to create this update command manually where normally I would just use:
I understand that the way I normally would do this probably isn't the best practice, and I "think" it's because I'm not checking for any concurrency violations on my fields.
My question is what are the benefits of doing the null check (@IsNull_employer_last_name = 1) AND (employer_last_name IS NULL)
And if it's strongly suggested that I include this in my update command, how do I add these parameters in code? I understand how to manually create parameters, just not the @Isnull_
When I create the data adapter in the design view it creates 300 parameters for just the update command, which if I create this in code would be alot of work, so I'm wondering if it's worth it.
Can someone just speak of the benefits of setting things up exactly how the designer would do it?
I'm using MS SQL 2008
In visual studio, when you use a data adapter in the designer to create the update command based off of your select command, you get extra parameters for Null checking, and also comparing the original values.
(command shortened for example)
Code:
UPDATE employer
SET employer_first_name = @employer_first_name, employer_last_name = @employer_last_name, emp_designation = @emp_designation
WHERE (employer_unique = @Original_employer_unique) AND (@IsNull_employer_first_name = 1) AND (employer_first_name IS NULL) AND
(@IsNull_employer_last_name = 1) AND (employer_last_name IS NULL) AND (@IsNull_emp_designation = 1) AND (emp_designation IS NULL) OR
(employer_unique = @Original_employer_unique) AND (employer_first_name = @Original_employer_first_name) AND (@IsNull_employer_last_name = 1) AND
(employer_last_name IS NULL) AND (@IsNull_emp_designation = 1) AND (emp_designation IS NULL) OR
(employer_unique = @Original_employer_unique) AND (@IsNull_employer_first_name = 1) AND (employer_first_name IS NULL) AND
(employer_last_name = @Original_employer_last_name) AND (@IsNull_emp_designation = 1) AND (emp_designation IS NULL) OR
(employer_unique = @Original_employer_unique) AND (employer_first_name = @Original_employer_first_name) AND
(employer_last_name = @Original_employer_last_name) AND (@IsNull_emp_designation = 1) AND (emp_designation IS NULL) OR
(employer_unique = @Original_employer_unique) AND (@IsNull_employer_first_name = 1) AND (employer_first_name IS NULL) AND
(@IsNull_employer_last_name = 1) AND (employer_last_name IS NULL) AND (emp_designation = @Original_emp_designation) OR
(employer_unique = @Original_employer_unique) AND (employer_first_name = @Original_employer_first_name) AND (@IsNull_employer_last_name = 1) AND
(employer_last_name IS NULL) AND (emp_designation = @Original_emp_designation) OR
(employer_unique = @Original_employer_unique) AND (@IsNull_employer_first_name = 1) AND (employer_first_name IS NULL) AND
(employer_last_name = @Original_employer_last_name) AND (emp_designation = @Original_emp_designation) OR
(employer_unique = @Original_employer_unique) AND (employer_first_name = @Original_employer_first_name) AND
(employer_last_name = @Original_employer_last_name) AND (emp_designation = @Original_emp_designation)
Code:
UPDATE employer
SET employer_first_name = @employer_first_name, employer_last_name = @employer_last_name
WHERE (employer_unique = @Original_employer_unique)
My question is what are the benefits of doing the null check (@IsNull_employer_last_name = 1) AND (employer_last_name IS NULL)
And if it's strongly suggested that I include this in my update command, how do I add these parameters in code? I understand how to manually create parameters, just not the @Isnull_
When I create the data adapter in the design view it creates 300 parameters for just the update command, which if I create this in code would be alot of work, so I'm wondering if it's worth it.
Can someone just speak of the benefits of setting things up exactly how the designer would do it?
I'm using MS SQL 2008