SQL Server 2005 with XML Parameters

We frequently have requirement like

Passing IDs in comma saperated value to the sql server for further processing.

Generally what we do is just create loop and get the value from it and ...

But SQL 2005 comes up with XQuery. Using this you can easly pass such type of data also some complex thing too.

For example...

DECLARE @productIds xml
SET @productIds ='<Products><id>9</id><id>18</id><id>27</id></Products>'

SELECT ParamValues.ID.value
('.','VARCHAR(20)')FROM @productIds.nodes('/Products/id')as ParamValues(ID)


Which gives us the following three rows:

9
18
27

Comments

Popular posts from this blog

Page Life Cycle in ASP.NET

ASP.NET MVC Version History

Auto Refresh .aspx page - ASP.NET

Introduction to ASP.Net MVC

How to Update Dependent Excel Cells Automatically

MVC Request Execution Stages - Life Cycle

Applying Dynamic Themes to WebPage

Abstract Class and An Interface

Differences between a Structure and Class