当试图运行将结果插入到sql表中的查询时,出现此错误。 即时传递表名作为参数,如何将层次结构值赋予插入语句。错误:使用storedprocedure插入层次结构值
这里是我的代码:
declare @pathhere hierarchyid
select @pathhere=Path from SectionDetails where [email protected] and [email protected] and [email protected] and [email protected] and [email protected]
插入语句:
set @sqlstmt = 'insert into '[email protected]+'(StudentID, StudentName,SectionID,SectionName,BatchID,BatchName, DeptID,DeptName, SchoolID,Path)
values('''[email protected]+''','''[email protected]+''','''[email protected]+''','''[email protected]+''','''[email protected]+''','''[email protected]+''','''+ @deptid+''','''[email protected]+''', '''[email protected]+''','+ CAST(@pathhere as hierarchyid)+')'
exec(@sqlstmt)
IM这一行收到错误:
'+ CAST(@pathhere as hierarchyid)+'
为Invalid operator for data type. Operator equals add, type equals hierarchyid.
任何人都可以请帮助我出去了如何传递层次结构值
此问题尚不清楚。你能格式化你的查询吗? – Galkin 2010-01-27 05:28:57