Gyan Prakash  Verma
Write a SQL Function to find the MAX and MIN number From String .
By Gyan Prakash Verma in .NET on Jan 08 2015
  • Gyan Prakash  Verma
    Jan, 2015 8

    declare @input varchar(100) declare @max int declare @min int declare @num int declare @counter int set @counter=1 set @input='20,402,32,5,0,-7,1158,55,99,-9,' --select charindex(',',@input),left(@input,charindex(',',@input)),len(@input),right(@input,len(@input)-charindex(',',@input)) while (len(@input)>0) begin set @num=left(@input,charindex(',',@input)-1) set @input = right(@input,len(@input)-charindex(',',@input))--print len(@input) if @counter=1beginset @max=@numset @min=@numend elsebeginif @max<@numset @max=@numif @min>@numset @min=@numendset @counter=@counter+1 endprint @max print @min

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS