I Tried to copy data's from one column to another column in same table by using following code.
UPDATE [dbo].[name] SET [name_HId] = [name_Id]
while running this query its showing an error which is
Operand type clash: int is incompatible with hierarchyid
Here the name_HId is in hierarchyid
datatype and the name_Id is in int
.
how can solve this problem?
add the slashes and then cast to hierarchyid
select cast('/' +cast(5 as varchar)+ '/' as hierarchyid)
When you cast a hierarchyid to string, it will look something like '/5/' or '/5/8/'
just cast the int value to varchar:
UPDATE [dbo].[name]
SET [name_HId] = Cast([name_Id] as varchar(max))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.