Quantcast
Viewing all articles
Browse latest Browse all 15889

inserting data from one table by splitting column-data into number of parts and storing it into another table.

Hi  ,

i am posting so many problems but upto now i haven't get any solution can any one help me to resolve the below problem

Table-1

CREATE TABLE MASTERT(CODE INT,DRUGNAME VARCHAR(20),ROUTE  VARCHAR(20))

INSERT MASTERT VALUES(2567,'30ML SESICON MG','SP')

INSERT MASTERT VALUES(1456,'30ML AMERIZOMERIS MG','SP')

INSERT MASTERT VALUES(246789,'30ML LOCTON-ZENIC MG','SP')

INSERT MASTERT VALUES(134,'30ML TWENTER ZAR ML','SP')

select * from mastert

Code                   DRUGNAME                      ROUTE

2567                   30ML    SESICON MG            SP

1456                   30ML  AMERIZOMERIS MG         SP

246789                 30ML  LOCTON-ZENIC MG         SP

TABLE2

CREATE TABLE DRUGDESRIPTION(CODE CHAR(3),DESCRIPTION VARCHAR(50))

INSERT DRUGDESRIPTION VALUES('SP','SPRUNPETA')

CODE         DESRIPTION

SP           SPRUNPETA

TABLE-3

CREATE TABLE DRUG

(CODE INT,

DRUGNAME VARCHAR(50),

ROUTE  VARCHAR(20),

UNIT INT,

MEASURE VARCHAR(20)

)

SELECT * FROM DRUG

now my expected out put is like below

CODE           DRUGNAME        ROUTE         UNIT         MEASURE

2567          SESICON          SPRUNPETA     30           MG

1456          AMERIZOMERIS     SPRUNPETA     30           ML

246789        LOCTON-ZENIC     SPRUNPETA     30           ML

it means i am getting the data from DRUGDESRIPTION and mastert tables and store it into DRUG table.

Note strickly remember under drugname column we cannot expect the length of drug name  data like in some fields (SESICON  , AMERIZOMERIS ,LOCTON-ZENIC here column length may also increase)

can any one help me as early as possible please.

Thanks in advance.


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>