I know how to do simple stuff in MS-SQL. But, I need to make a database change
that I am not confident about.
The database is on an MS-SQL server.
I realize this is not a Midrange-specific question, and I apologize for that.
Basically, I need to populate two columns in one table with corresponding values
from another table. But only under specific circumstances.
I do not want to change the first table's values if they are already populated.
In the case of this database, there can be no valid dates prior to 11/01/1999.
The database design is not mine. The vendor is using two date-time columns,
one stores actual date and a time of zero. The second stores the default date
1/1/1800 and the actual time.
What I have come up with, I present below. It is incomplete. I do not know how
to specify the second table properly. The two tables are POST_PROCEDURE which I
want to selectively update, and POST_ANESTHESIA_TYPE, which has the data I need.
The two tables have a common column, CASE_NO.
Any help is appreciated.
Here is what I have come up with:
UPDATE POST_PROCEDURE p
SET p.START_DATE = , p.START_TIME =
WHERE p.CASE_NO = a.CASE_NO
AND p.PROCEDURE_ID = '131200'
AND p.START_DATE < '11/01/1999'
This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact