January 8, 2007 at 4:03 am
have a SP here is the code of that ::
CREATE PROCEDURE AddNewCountry
@CountryName varchar(50),
@CountryCode varchar(5)
AS
IF exists(Select CountryName from Countries where CountryCode=@CountryCode and CountryName=@CountryName)
begin
raiserror('Country Already Exist',16,1)
end
else
begin
INSERT INTO Countries
VALUES
(@CountryName,
@CountryCode)
end
GO
the problem is that if i have 092 and pakistan it gives me msg already registered but if i check 092 and America it check but no entry fooud as i used and so false and it added new entry in Coutry table as u see 092 is the code of Pakistan so code duplicates problem occurs
now i want to make changes in the SP entry inserted if both are not present in the table how can i do this plz tell me.
help me............
January 8, 2007 at 6:37 am
how about change the and to an or?
January 10, 2007 at 9:13 am
an understanding of relational database design would be useful, I'd suggest a training course or a good book on T-SQL.
[font="Comic Sans MS"]The GrumpyOldDBA[/font]
www.grumpyolddba.co.uk
http://sqlblogcasts.com/blogs/grumpyolddba/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply