How can i loop on each row and apply a specific function on it using sql-server -




enter image description herei need loop on each resulted row xml code. applied function want taking details in first row , search in data base reference information, once found need update row information , on.

here code takes information , returns table of rows numbers required information data base:

alter procedure [dbo].[multi_valued_user_input_parameter](@productkey  varchar(max)) begin  declare @xml xml,@str varchar(100),@delimiter varchar(10) set @str = @productkey set @delimiter =',' set @xml = cast(('<x>'+replace(@str,@delimiter ,'</x><x>')+'</x>') xml) select n.value('.', 'varchar(10)') value @xml.nodes('x') t(n)  end 

update !!

here multi_valued_user_input_parameter function

'

alter procedure [dbo].[multi_valued_user_input_parameter](@productkey  varchar(max))  begin  declare @xml xml,@str varchar(100),@delimiter varchar(10) set @str = @productkey set @delimiter =',' set @xml = cast(('<x>'+replace(@str,@delimiter ,'</x><x>')+'</x>') xml) select n.value('.', 'varchar(10)') value @xml.nodes('x') t(n)      end 

'

i need use function input parametes " 123456,789123,4567" need take " 123456" , apply function on it, value of function updated , put first row of table

i need them listed in rows under each other not in separated tables

create table #prodlist (     [id] int identity(1,1) ,     [prodkey] varchar(100)     )  --insert data temp table     insert #prodlist     exec [dbo].[multi_valued_user_input_parameter] n'aaaa,bbbb,cccc,ddddd,eeeee'  declare @curcount int , @maxcount int     select @curcount = 1 ,@maxcount = max(id)  #prodlist  while @curcount <=@maxcount     begin        -- can replcase code table adn logic        select * #prodlist id = @curcount     set @curcount = @curcount+1     end  




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -