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
 openrowset and parameter issue

Author  Topic 

Nader
Starting Member

41 Posts

Posted - 2010-05-04 : 13:38:49
On writing this code I obtain personXML and it is displayed on selecting @personxml
-------------------------------------------------------
set @XMLFileName='d:\sample\person.xml'

-- retrieve the file content as xml
set @mysql=N'select PersonXML=
CONVERT(xml, BulkColumn, 2) FROM
OPENROWSET(Bulk '''+ @XMLFileName+''', SINGLE_BLOB) [rowsetresults]'


Set @ParamDefinition = '@XMLFileName nvarchar(max)'
Execute sp_Executesql @mySql,
@ParamDefinition,
@XMLFileName
select @PersonXML

---------------------------------------
I can see the content of PersonXML
but the following does not work althu It worked when I had coded @personxml
i.e. when I provide the content
-------------------------------
select
@Pass= @PersonXML.value('(//@password)[1]','nvarchar(20)'),
@FirstName=@PersonXML.value('(/enterprise/person/name/n/given)[1]','nvarchar(50)')

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 13:41:51
you mean the second part didnt work inside dynamic sql?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Nader
Starting Member

41 Posts

Posted - 2010-05-04 : 21:13:16
Thanks it is fixed now. I assigned the variable as output
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-05 : 02:17:46
oh great

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -