Thursday, January 11, 2007 7:50 AM
i m using SQL Server 2000, in this i have the follwowing SP,
CREATE PROCEDURE AddNewCountry
IF exists(Select CountryName from Countries where CountryCode=@CountryCode or CountryName=@CountryName)
raiserror('Country Already Exist',16,1)
INSERT INTO Countries
in this SP in the where clause i used the following line :
IF exists(Select CountryName from Countries where CountryCode=@CountryCode or CountryName=@CountryName) (used OR operator)
but it inserted the data if i give 092,'america'
and if i used AND operator it chekc 092, 'america' if yes then shows error but if i give 092,'Japan' it inserted new row in the Countries table.
plz give me some other idea what changes i made in my SP as unique Country added with unique Code. if code exists then not allowed to used to enter data in the table same in
the case of country name .
plz give me idea what updation i made as after this my SP works fine.