Yes, I was doing some funky things with text pointer that was not
going to work.
So based on your suggestion, I tried this:
update TargetTable set TargetTable.TargetFloatValue = (select
convert(float, convert(nvarchar, OtherTable.NTextValue)) from
OtherTable where OtherTable.ID = @id) where TargetTable.ID = @id
And I get the following error:
"Error converting data type nvarchar to float."
Which really surprises me because it is basically what you have
written and because the following works:
updatetext TargetTable TargetTable.NTextValue @ptrText 0 NULL
OtherTable.NTextValue @valuePointer
update TargetTable set TargetTable.TargetFloatValue = convert(float,
convert (nvarchar, TargetTable.NTextValue)) where TargetTable.ID =
@id
update TargetTable set TargetTable.NTextValue = NULL where
TargetTable.ID = @id
However, even though this appears to be working, I am using an
intermediate table field which I have to clear after I have converted
and move the value over and I do not want to execute 3 update queries
if I can only do one.
Your help is appreciated,
Cally
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Cally (ze**********@hotmail.com) writes: I would like to convert a field from ntext field found in one database
table to float field found in another database table. The reason why I
want to do this is a long one.
I have tried the following and playing around with the following:
declare @valuePointer varbinary(16)
<Row cursor logic to initialize @valuePointer to be a pointer to the
source ntext field>
update TargetFloatTable set TargetFloatTable.TargetFloatValue =
CAST(CAST(@valuePointer AS nvarchar) AS float)
where TargetFloatTable.Id = @Id
but is not working for me.
You are trying to convert the text pointer to float - that is not
very likely to succeed. Here is an example that works:
CREATE TABLE nt (a int, n ntext)
go
INSERT nt (a, n) values (1, '9.234E30')
go
select convert(float, convert(nvarchar, n)) from nt