mercredi 25 novembre 2015

Doing validation in Stored Procedure if data already exist

I want to create a storedprocedure where I want to check if I add a Bin no and if exist in the table it should give me validation message otherwise it should work

I tried like below but it is not working

ALTER PROCEDURE [dbo].[sp_P_WMS_Stock_Adj_Val_Proc]
 (@Bin_no nvarchar(max)) AS BEGIN
 IF (@Bin_no=)
        BEGIN
          RAISERROR('Bin no already exist', 16, 1)
          RETURN
        END

ELSE
   BEGIN
    select distinct  Location_Name + '-' +  convert(varchar, mkey) 
    from WMS_Storage_Bin where status='Confirmed' and location_name=@Bin_no
END END

I am using sql server 2005

Aucun commentaire:

Enregistrer un commentaire