June 5, 2005 at 11:44 am
Hi all,
Is there a way to write a sql script to do the following tasks?
If the Subj_Num and Scan_date in table IMG_WHOLE_BRAIN matches with Subj_Num and Scan_date in the table mrisession, then insert the value from Magnet_strength_in_gauss in mrisession table into Magnet_strength_in_gauss in IMG_WHOLE_BRAIN
Tables information:
Table Name: IMG_WHOLE_BRAIN
Fields name:
Subj_Num data type: int
Scan_date data type: datetime
Magnet_strength_in_gauss data type: decimal
#########################################
Table name: mrisession
Fields name:
Magnet_strength_in_gauss data type: decimal
Exam_DATE_stamp data type: datetime
subj_num data type: int
////////////
We have already around 1000 records in IMG_WHOLE_BRAIN table with no value in the dbo.IMG_WHOLE_BRAIN.Magnet_strength_in_gauss field.
I tried the following script, but it did not work:
SELECT dbo.mrisession.Magnet_strength_in_gauss
from dbo.mrisession , dbo.IMG_WHOLE_BRAIN
where dbo.IMG_WHOLE_BRAIN.SUBJ_NUM = dbo.mrisession.subj_num
AND dbo.IMG_WHOLE_BRAIN.scan_date = dbo.mrisession.Exam_DATE_stamp
INSERT INTO dbo.IMG_WHOLE_BRAIN.Magnet_strength_in_gauss
//////////////////////////////////////////////////
Thanks for any help.
Abrahim
June 8, 2005 at 8:00 am
This was removed by the editor as SPAM
June 8, 2005 at 8:19 pm
The following update query should do what you want:
update dbo.IMG_WHOLE_BRAIN
set Scan_Date = MRI.Exam_DATE_stamp
from dbo.IMG_WHOLE_BRAIN as IWB
join dbo.mrisession as MRI
on IWB.Subj_Num = MRI.Subj_Num and
IWB.Magnet_strength_in_gauss = MRI.Magnet_strength_in_gauss
Rick Phillips
June 9, 2005 at 9:27 am
Thanks Rick ,
I'll give it try.
Regards,
Abrahim
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply