Passing XML Parameter in Stored Procedure

In this SP,
One of the Parameter @LocationIds is XML Parameter.

sample value for @LocationIds is





@Locations table will contain all the ids

CREATE PROCEDURE [dbo].[Sample]
(

@LocationIds xml,
@debug int=0
)

declare @Locations TABLE (LocationId int,ID int identity)

insert into @Locations (LocationId)
SELECT ParamValues.ID.value('.','VARCHAR(20)')
FROM @LocationIds.nodes('Location/Id') as ParamValues(ID)


if @debug = 1
begin
select * from @Locations
print 'Recipients of StateInspection:'
declare @Cnt8 int
set @Cnt8= (select count(*) from @Locations)
print @Cnt8
end

exec [dbo].[Sample]

1 comment:

ஜிம்ஷா said...

hai! i am gimsha from chennai done.