INDEXING CREATE & PERMISSION FOR USER
https://www.techonthenet.com/sql_server/indexes.php ALTER procedure [dbo].[AddNumberFromString] as begin DECLARE @string varchar(100) Declare @addstr int SET @string = 'ma46h1es2hgggggg5' set @addstr=0 WHILE PATINDEX('%[^0-9]%',@string) <> 0 SET @string = STUFF(@string,PATINDEX('%[^0-9]%',@string),1,'') declare @count int set @count=1 while(@count<=len(@string)) begin set @addstr=(SUBSTRING(@string,@count,1))+@addstr set @count=@count+1 end select @addstr as total end -------Missing Number--------------------------- SELECT ID2, Name2, City2, PinCode2 FROM [dbo].[tbl2] DECLARE @tempdata AS TABLE ( ID INT ) DECLARE @MaxID INT = 0, @Counter INT = 1 SELECT @MaxID = MAX(ID2) FROM [dbo].[tbl2] WHILE (@Counter < @MaxID) BEGIN INSERT INTO @tempdata VALUES (@Counter) SET @Counter = @Counter + 1 END SELECT ID FROM @tempdata AS T LEFT JOIN [dbo].[tbl2] AS T2 ON (T2.ID2 = T.ID) WHERE T2.ID2 IS NULL