all groups > sql server programming > november 2006 >
You're in the

sql server programming

group:

Update Table Query


Update Table Query Christine C
11/22/2006 10:15:01 PM
sql server programming:
I have a database with 2 tables (Table1 & Table2).

I want to update Column1.Table1 using the value from Column2.Table2 where
Column3.Table1 = Column4.Table2 AND Column2.Table2 IS NOT NULL.

The datatype for Column1.Table1 is in DATETIME. The datatype for
Column2.Table2 is in NVARCHAR(50). An example of the value in Column2.Table2
is: 01/01/2006, assuming all values in Column2.Table2 is in format
dd/mm/yyyy.

What is the best way to tackle this in SQL Server 2000 and how?

Re: Update Table Query Uri Dimant
11/23/2006 12:00:00 AM
Christine

UPDATE Table1 SET Column1 =Column2 FROM Table2 JOIN
Table1 ON Table1.Column3= Table1.Column4 AND Table2.Column2 IS NOT NULL







[quoted text, click to view]

Re: Update Table Query Christine C
11/26/2006 4:48:01 PM
Thanks Uri.

Below is the actual statement:
UPDATE Reprinting
SET EvaluatedDate = [Evaluation Date]
FROM Evaluated
JOIN Reprinting ON
(Reprinting.p1 + '/' +
Reprinting.p2 + '/' +
Reprinting.p3 + '/' +
Reprinting.ppp + '/' +
Reprinting.bbb + '/' +
CAST(Reprinting.RefNo_Print AS VARCHAR(5)) + '/' +
Reprinting.reprintno)
= Evaluated.[pan number]
AND Evaluated.[Evaluation Date] IS NOT NULL

I have ran the update statement above but i get this error:
Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.

I think i need to convert the Evaluated.[Evaluation Date] (Table2.column2)
from NVARCHAR(50) to DATETIME first. But I am not sure how to write this
query. Can you please help?

Thanks again.


[quoted text, click to view]
AddThis Social Bookmark Button