ALTER proc [dbo].[pGetCode] --'InvestmentGroup', 'Code', 'I',5 ( @TableName varchar(20), @ColumnName varchar(20)='', @key varchar(10), @TotalDigits int ) as begin create table #temp (incode varchar(20)); declare @incode varchar(20); declare @a varchar(10)=null; declare @length int = 1; declare @string varchar(10) =''; declare @startposition varchar(20); declare @query varchar(100); set @startposition=Len(@key)+1; select @query='insert into #temp select SUBSTRING( max('+@ColumnName+') ,'+@startposition+','+@TotalDigits+') as int from '+ @TableName +' where '+@ColumnName+' like '''+ @key +'0%''' exec (@query) select @incode = incode from #temp; select @incode drop table #temp; end
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)