Single stored procedure for insert update and delete and select in sql server

Here, you create a stored procedure with INSERT, SELECT, UPDATE, and DELETE SQL statements. 
 The INSERT statement is 
used to add new rows to a table. The SELECT SQL statement is used to fetch rows from a database table. The UPDATE statement is used to edit and update values of 
an existing record. The DELETE statement is used to delete records (Use with condition) from a database table.
 The following SQL stored procedure is used select insert, update and delete rows from a table, 
depending on the statement type parameter.

CREATE proc [dbo].[ProcName](              
               
  @Entity_Name varchar(max),              
  @Records_Fields varchar(max),              
  @Records_Values varchar(max),              
  @Action_Type CHAR(2)         
         
)            
as begin             
          
  declare @querryString varchar(max)            
             
          
  if(@Action_Type='I')              
     begin                    
       SET @querryString='insert into'+' '+ isnull(@Entity_Name,'') +'('+isnull(@Records_Fields,'') +') values'+'('+isnull(@Records_Values,'')+')'               
     end              
  else if(@Action_Type='U')              
     begin                    
       SET @querryString='Update '+ ' '+  isnull(@Entity_Name,'') +' ' +'SET' +' '+ @Records_Fields+ ' '+'where' +' '+@Records_Values                        
     end              
 else if(@Action_Type='D')              
     begin                    
       SET @querryString='Delete from '+ ' '+  isnull(@Entity_Name,'') +' '+'where' +' '+@Records_Values               
     end              
              
 else if(@Action_Type='G')              
     begin                
       IF (@Records_Values='')               
         Begin                          
           SET @querryString='Select' +' '+ @Records_Fields+' '+' from '+' ' +@Entity_Name              
         End              
       ELSE               
         Begin              
           SET @querryString='Select ' +' '+ @Records_Fields+' '+' from '+' ' +@Entity_Name +' '+'where' +' '+@Records_Values               
         End              
     end              
   else if(@Records_Values='P')
   begin
  set @Action_Type='G'
   SET @querryString=@Entity_Name +' '+  @Records_Fields
   print @querryString
   end          
exec (@querryString)        
END

Working fine.....

2020-01-15