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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 openrowset and using a variable for file name erro

Author  Topic 

Nader
Starting Member

41 Posts

Posted - 2010-05-03 : 17:11:04
Please can you help me fix this error message
declare @filename nvarchar (100)
declare @mysql nvarchar (500)
declare @PersonXML xml
declare @ParamDefinition nvarchar(max)

set @filename='C:\GoThruFiles\Person.xml'

set @mysql=N'select @PersonXML=
CONVERT(xml, BulkColumn, 2) FROM
OPENROWSET(Bulk '''+ @filename+''', SINGLE_BLOB) [rowsetresults]'

select @mysql
Set @ParamDefinition = '@filename nvarchar(max)'
Execute sp_Executesql @mySql, @ParamDefinition,@filename


I am getting an error message
Must declare the scalar variable "@PersonalXML".

I want to set the value of @PersonalXML to the content of the file 'C:\GoThruFiles\Person.xml'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-04 : 04:16:38
you have declare the variable in @paramdefinition of type output to get value back

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

Go to Top of Page
   

- Advertisement -