Suraj Dubey

Suraj Dubey

  • 797
  • 821
  • 43k

How to pass string list as parameter in stored procedure

Apr 6 2022 12:45 PM

Hello fiends i am creating on stored procedure but i am not able to pass list as paramter code is as following

USE [DBdiamond]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE OR ALTER PROCEDURE [dbo].[ListDiamonds]
(
     @shape Nvarchar(Max)=null
) AS
BEGIN    
         if @shape='' or @shape='NULL'
         BEGIN
             select * from Diamondmst; 
         END;
         ELSE
         BEGIN
             select * from Diamondmst d where d.shape IN (@shape);
         END;
END;


i want to pass the @shape like @share='ROUND','PEAR'

so how can i pass sting list pls suggest

 

 


Answers (4)