Simple...

  • I am trying to come with a SQL statement to do the following.

    I have two tables in a DB.

    One table has user information in it while the other has personal user information like address phone number and such. What I want to do is insert the personal information from table 2 into table one. Heres where it gets tricky. Table one has two columns that make up a unique ID For instance:

    col1 col2

    abc 123

    Table 2 has just one columns with both these values:

    col1

    abc123

    How do I insert the information from table two into table one into there respective columns according to table 2's joined unique ID wich are represented in two columns in table one. Also I need to loop throught the records and do this automatiaclly.

    Currently I am using a DTS package to get the data from two different text files. One again makes up table one and the second table two.

    Any help would help

  • INSERT INTO TABLE1(COL1, COL2) SELECT LTRIM(LEFT((COL1 + REPLICATE(' ', 6)), 3)), LTRIM(RIGHT((COL1 + REPLICATE(' ', 6)), 3)) FROM TABLE2

    This makes sure that the query will not fail in case of 5 or less characters from table2.

    Prasath.



    Prasath.

  • Is your column in the Table 2 always will have the structure abs123, or you will have different size of strings?

    Edited by - EPol29 on 04/10/2002 08:08:25 AM

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply