For Programmers: Free Programming Magazines  


Home > Archive > MSDN > November 2004 > dynamic sql and openxml









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author dynamic sql and openxml
Sher

2004-11-05, 3:55 pm

Any idea of why the cast in this statment would give an error? See a printout
of the statement below. The error text "Syntax error near cast". Or in the
case of running the printed statement the error is "Syntax error near 5".

*****Dynamic sql ***********
set @sqlXml = ' SELECT @newValue = xmlEEBank.' + @sqlFieldName + ' ,
@empnum = xmlEEBank.empnum FROM OPENXML(' + cast(@hDoc as nvarchar(10)) + ',
''/ROOT/EEbank'') with EEBank xmlEEBank'

EXECUTE sp_executesql @sqlXml, @params, @newValue = '', @empnum = '', @hDoc
= @hDoc

*************Printed statement*************
SELECT @newValue = xmlEEBank.Bank1Name , @empnum = xmlEEBank.empnum FROM
OPENXML(5, '/ROOT/EEbank') with EEBank xmlEEBank

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com