Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML parameter is NULL to indicate all values should be returned

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all,

I'm passing a list of values to a stored procedure using an XML parameter.

The stored procedure is used to search a table for matching values so this list can contain one or many values, or could be NULL to indicate all values should be returned.

How can I phrase my query to cope with the scenario of the parameter being NULL to select all values?

I currently have the following code to cope with one or many values being passed:

Code:
SELECT * FROM dbo.MyTable
WHERE idField IN 
(SELECT paramvalues.id.value('.', 'int') FROM @testxml.nodes('/rootnode/idfieldvalue') as paramvalues(id))

Thanks as always


Craftor
:cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top