Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 migration script needed

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 05:21:18
[code]
hi iam having two tables where data migration should be done
tables are :

Table1:EMRFPD

column datatype

IS_MENARCH VARCHAR

Table2: EMRFRExamData:

column datatype

FR_EXAM_DATA_ID numeric
PATIENT_ID numeric
ENCOUNTER_ID numeric

Table3:EMRFRExamAns:

column datatype

FR_EXAM_ANS_ID numeric
FR_EXAM_DATA_ID numeric
QUES_ID numeric
QUES_ANS_ID numeric
CTRL_VALUE varchar
DISP_LABEL varchar


ONLY MIGRATION HAS TO BE DONE IF IS_MENARCH FROM EMRFPD VALUES ARE '1' ONLY
EMRFRExamData table holding records.

EMRFRExamAns needs to be migrated now

a)FR_EXAM_ANS_ID has to be generated with a sequence starting with some number 1500 foe example.

b)FR_EXAM_DATA_ID values has to be taken from table 2

c)QUES_ID,QUES_ANS_ID both from Table EMRFRQUESLKUP columns QUES_ID,QUES_ANS_ID

d)CTRL_VALUE,DISP_LABEL are to be taken by

EMRFRANSLKUP TABLE WHICH HAVING THREE COLUMNS

ANS_ID ANS_LABEL CTRL_TYPE
INT VARCHAR VARCHAR

1. IF ANS_LABEL IS YES THEN
CTRL_VALUE=YES AND DISP_LABEL=NULL

2. IF ANS_LABEL IS DATE THEN
CTRL_VALUE=DATE AND DISP_LABEL=NULL

3. IF ANS_LABEL IS OTHER THAN YES AND DATE THEN
CTRL_VALUE=1 AND DISP_LABEL=THAT PATICULAR COLUMN VALUE


[/code]

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:21:14
hi can anyone please help me in doing this so
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:23:33
how do you relate table 1 with others? it just has a IS_MENARCH field alone??
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:25:55
no it is already done now i want for the last table.how can i do so.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:28:04
sorry i dont get what you're asking for. dont you need to consider table1's field for migrating data to table3?
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:30:31
no actually first and second table refers that and has been done .now its turn for third table considering with the second one
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:40:57
Hi any stored procedure in this help will be appreciated
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:44:09
how is EMRFRQUESLKUP related to exam data?
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:47:16
Actually i have to migrate it from 3-4 tables.All are seperate tables here.These are newly created tables where existing data should go into those
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:49:07
then how do you decide which row of one table should be linked to other?
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:50:38
First column will be generated in a sequence,second column should get from second table,third and fourth columns from another
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:53:07
there's no concept of sequence in sql table.
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:54:17
sorry it has to be generated foe example starting with 1500
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 13:57:10
please understand what i'm talking about. your first column sequence can be generated by making it an identity column. what i'm telling is you need a way (column(s)) by virtue of which you can link data from table 2 & other and take related col2,col3,col4 values for table 1
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-12-11 : 13:59:50
Can you give me at least some tried script as of there is no link between 1 and 3 tables
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-12-11 : 14:40:06
You need to follow the "How to ask" link in my signature.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-14 : 08:58:48
quote:
Originally posted by DonAtWork

You need to follow the "How to ask" link in my signature.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


No matter how many times you tell him, he wont listen
He will stop as soon as he gets what he wants or if more questions are asked. See his recent threads

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -