hi guys, Following is a storedprocedure in which iam passing DriverID=0 and DrivarCode =DD1 and DriverName =Ram. While executing control is going to fails.Control is coming to IF ((@DriverName!=NULL) and ((@DriverCode!=NULL)),After that going to fails. DriverName and DriverCode contains values.But still going to fails .What may be the reason for this
Create Procedure InsertUpdateM
(
@DriverID int,
@DriverCode varchar(50),
@DriverName varchar(50),
@Msg varchar(50) output
)
AS
BEGIN
IF @DriverID=0
BEGIN
SELECT DriverName,DriverCode FROM DriverM WHERE DriverName=@DriverName and DriverCode=@DriverCode
IF(@@RowCount>0) GOTO Fails
IF ((@DriverName!=NULL) and ((@DriverCode!=NULL))
BEGIN
INSERT INTO DriverM(DriverCode,DriverName) values(@DriverCode,@DriverName)
END
END
ELSE
BEGIN
SELECT DriverName,DriverCode FROM DriverM WHERE DriverName=@DriverName and DriverCode=@DriverCode
IF(@@RowCount>0) GOTO Fails
IF ((@DriverName!=NULL) and ((@DriverCode!=NULL)
BEGIN
UPDATE DriverM SET DriverCode=@DriverCode,DriverName=@DriverName WHERE DriverID=@DriverID
END
END
END
Fails
SET @Msg='Failed'