ODBC stage doesn't run valid SQL statement
Posted: Wed Oct 05, 2011 12:12 pm
I have this SQL statement that runs fine using the SQL Server client:
with fix_hra (id, name, version, META_DATA) as (select ID,convert(varchar(255),NAME) NAME, version,CONVERT(xml,meta_data) META_DATA from HRA)
SELECT
ID,
NAME,
Version,
Q.value('(@id)[1]', 'varchar(9)') AS 'QuestionID',
Q.value('(@type)[1]', 'varchar(40)') AS 'QuestionType',
Q.value('(@conceptid)[1]', 'varchar(9)') AS 'QuestionConceptID',
Q.value('(@value)[1]', 'varchar(255)') AS 'QuestionValue',
OPT.value('(@id)[1]', 'varchar(9)') AS 'OptionID',
OPT.value('(@value)[1]', 'varchar(255)') AS 'OptionValue'
FROM fix_hra
CROSS APPLY META_DATA.nodes('HRA/PAGE/CONDITION/QUESTION') AS QS(Q)
CROSS APPLY QS.Q.nodes('./OPTIONS/OPTION') AS OPTS(OPT)
but when I copy it into the ODBC stage I get this error:
Incorrect syntax near keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
I tried putting a semicolon in front of the statement but then I get error:
Null argument: pDataSetDef
Has anybody dealt with this problem before?
with fix_hra (id, name, version, META_DATA) as (select ID,convert(varchar(255),NAME) NAME, version,CONVERT(xml,meta_data) META_DATA from HRA)
SELECT
ID,
NAME,
Version,
Q.value('(@id)[1]', 'varchar(9)') AS 'QuestionID',
Q.value('(@type)[1]', 'varchar(40)') AS 'QuestionType',
Q.value('(@conceptid)[1]', 'varchar(9)') AS 'QuestionConceptID',
Q.value('(@value)[1]', 'varchar(255)') AS 'QuestionValue',
OPT.value('(@id)[1]', 'varchar(9)') AS 'OptionID',
OPT.value('(@value)[1]', 'varchar(255)') AS 'OptionValue'
FROM fix_hra
CROSS APPLY META_DATA.nodes('HRA/PAGE/CONDITION/QUESTION') AS QS(Q)
CROSS APPLY QS.Q.nodes('./OPTIONS/OPTION') AS OPTS(OPT)
but when I copy it into the ODBC stage I get this error:
Incorrect syntax near keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
I tried putting a semicolon in front of the statement but then I get error:
Null argument: pDataSetDef
Has anybody dealt with this problem before?