cancel
Showing results for 
Search instead for 
Did you mean: 

Code not working

former_member645084
Participant
0 Kudos

Hi

There are 2 records of Customer . In one first 2 character is 06. In second it is null.

IT should give error message since value is Null not 06.

IF @object_type = '2' and @transaction_type in ('A','U')
BEGIN
	SELECT TOP 1 @error = '1', @error_message = ''
	FROM CRD1 
	WHERE CRD1.CardCode = @list_of_cols_val_tab_del 
	AND (Substring(CRD1.[GSTRegnNo],1,2) <> '06' )
END

Thanks

View Entire Topic
Johan_H
Active Contributor
0 Kudos

Hi,

When the value is NULL it will not be validated. Please try this:

IF @object_type ='2' and @transaction_type in ('A','U')
  BEGIN
    SELECT TOP1 @error ='1', @error_message =''
    FROM CRD1 
    WHERE CRD1.CardCode =@list_of_cols_val_tab_del 
       AND(Substring(ISNULL(CRD1.[GSTRegnNo],'xx'),1,2)<>'06')
  END

Regards,

Johan