Hello Friends-
I have faced a problem related to Update Statement in SQL Server.
My SQL Statement is:
DECLARE @OrgID INT
SET @OrgID=10
UPDATE MYTable Set OrgID=@OrgID WHERE CountryID=@CountryID, StateID=@StateID and OrgName=@OrgName
@CountryID,@StateID,@OrgName are the three parameters that i need to pass from application.
Suppose i have one Column Name UserID in MyTable and that is having Foreign key relation with the User Table.
the above statement is working fine when record exists for the above given condition. But when there is no row exists for the above condition its giving error related to Foreign key relation of UserID with User Table. if i'll add the if exists before Update then its working fine.
But Problem is, when there is no record to update then why its giving me error related to UserID (Foreign key).
Thanks & Regards
Lakhan Pal Garg