Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 XML issue

Author  Topic 

divyaram
Posting Yak Master

180 Posts

Posted - 2010-01-11 : 04:58:06
Hi all,


i want to get all details of journals...by passing journalid ... sometimes i have
get some many journals details... so i have decided like input parameter is passed as
xml parameter ..but Sp is not working .. its not showing any details in the output...
this how i have done it.. please help to resolve this issue



my SP is like this


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/*

exec SelectByJournalIdList '<id> 3 </id>'
*/

ALTER PROCEDURE [dbo].[SelectByJournalIdList](@JournalIds xml) AS

DECLARE @Journals TABLE (ID int)
declare @idoc int

INSERT INTO @Journals(ID)
SELECT Node.value('.','VARCHAR(20)')
FROM @JournalIds.nodes('/Journals/id') as ParamValues(ID)

SELECT * FROM dbo.FIS_Field as f --Products
INNER JOIN
@Journals j
ON f.Field_ID= j.ID
--Products.ProductID = p.ID




Regards,
Divya

divyaram
Posting Yak Master

180 Posts

Posted - 2010-01-11 : 05:04:25
i have made a little change in slect statement


INSERT INTO @Journals(ID)
SELECT Node.value('ID','VARCHAR(20)')
FROM @JournalIds.nodes('/Journals/id') as ParamValues(ID)

im getting error like this

Msg 4121, Level 16, State 1, Procedure SelectByJournalIdList, Line 12
Cannot find either column "Node" or the user-defined function or aggregate "Node.value", or the name is ambiguous.


Regards,
Divya
Go to Top of Page

divyaram
Posting Yak Master

180 Posts

Posted - 2010-01-11 : 05:25:41
Hi all,,


atlast i found it out now its working fine


/*

exec SelectByJournalIdList '<Journals><id value="3"/><id value="1"/></Journals>'*/

ALTER PROCEDURE [dbo].[SelectByJournalIdList](@JournalIds xml) AS

DECLARE @Journals TABLE (ID int)
declare @idoc int

INSERT INTO @Journals(ID)
SELECT Node.value('@value','VARCHAR(20)')AS a
FROM @JournalIds.nodes('/Journals/id') as ParamValues(Node)

SELECT * FROM dbo.FIS_Field as f --Products
INNER JOIN
@Journals j
ON f.Field_ID= j.ID



Regards,
Divya
Go to Top of Page
   

- Advertisement -