SQLのテーブルに結果を挿入するクエリを実行しようとすると、このエラーが発生します。テーブル名をパラメーターとして渡す場合、挿入ステートメントに階層値を与える方法。
これが私のコードです:
declare @pathhere hierarchyid
select @pathhere=Path from SectionDetails where Sectionid=@sectionid and SectionName=@sectionname and Batchid=@batchid and Deptid=@deptid and Schoolid=@schoolid
stmtを挿入:
set @sqlstmt = 'insert into '+@batch+'(StudentID, StudentName,SectionID,SectionName,BatchID,BatchName, DeptID,DeptName, SchoolID,Path)
values('''+@sectionid+''','''+@sectionname+''','''+@sectionid+''','''+@sectionname+''','''+@batchid+''','''+@batchname+''','''+ @deptid+''','''+@deptname+''', '''+@schoolid+''','+ CAST(@pathhere as hierarchyid)+')'
exec(@sqlstmt)
この行でエラーが発生しています:
'+ CAST(@pathhere as hierarchyid)+'
なのでInvalid operator for data type. Operator equals add, type equals hierarchyid.
誰かplsが階層値を渡す方法を教えてくれますか