June 15, 2009 at 7:23 am
I have to update a table based on a column from one table to the column of the other table.
Table1(DetailId(int), ColumnName(varchar(50))
Table2(Order_Comments(text), ColumnName(varchar(50))
Update Table1
Set ColumnName = t2.ColumnName
FROM Table1 t1, Table2 t2
WHERE t1.DetailId = CAST(t2.Order_Comments As int)
I get an error when I do this - can't convert text to an int.
I try casting both as varchar, but it doesn't work.
Update Table1
Set ColumnName = t2.ColumnName
FROM Table1 t1, Table2 t2
WHERE CAST(t1.DetailId As varchar(50)) = CAST(t2.Order_Comments As varchar(50))
I can't change the datatype of Order_Comments in table2 since its done that way. The detailid is stored in table2 in the Order_Comments field.
June 15, 2009 at 7:44 am
This contains how u update data to a column with text data type
http://msdn.microsoft.com/en-us/library/ms177523.aspx
Look at examples 'G' & 'H' there.
June 15, 2009 at 8:35 am
Thanks PS. That helped.
June 15, 2009 at 8:38 am
bladerunner148 (6/15/2009)
Thanks PS. That helped.
You're welcome:-)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply