Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160

    Unanswered: select * into table1 from table2 - Problem

    i noticed something when i was doing

    select * into table1 from table2 that


    1 - All Columns Have to be the Same size = Understandable

    2 - All Columns have to be in the same order in both tables (this makes no sense) im getting a "String or Binary Data Will Be Truncated"

    "Both tables have the same columns just not in order"

    To me it seems that it is matching up col1 with col1 and col2 with col2 as apposed to the column names

    is there something i am missing??

    any suggestions to get around this ???

    need some solution or advice to create my own solution ASAP - found this error at work and shit needs to be done (a lot of u know how it is)

    thanks
    Beyond Limitation

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322

    Re: select * into table1 from table2 - Problem

    Canm you post some DDL, DML, and sample data?

    I don't have that problem...

    Code:
    USE Northwind
    GO
    SELECT * INTO OrderDetails FROM [Order Details]
    GO
    
    SELECT * FROM OrderDetails
    GO
    SELECT * FROM [Order Details]
    GO
    
    sp_Help OrderDetails
    GO
    sp_Help [Order Details]
    GO
    
    
    DROP TABLE OrderDetails
    GO

  3. #3
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    My Fault : wrong query i wrote (damn copy & paste)
    =========================

    insert into Table1 select * from table2

    =========================
    Format for Tables Displayed Below
    <Column Name> <Size>

    Table1
    =====
    ACCOUNTNO 7
    D01_OTHR 30
    D02_OTHR 30
    D03_OTHR 30
    D04_OTHR 30
    D05_OTHR 1
    D06_OTHR 1
    D07_OTHR 1
    D08_OTHR 1
    MATCHCODE 10
    CODELINE1 30
    CODELINE2 30
    CODELINE3 3


    table2
    =====
    ACCOUNTNO 7
    MATCHCODE 10
    D01_OTHR 30
    D02_OTHR 30
    D03_OTHR 30
    D04_OTHR 30
    D05_OTHR 1
    D06_OTHR 1
    D07_OTHR 1
    D08_OTHR 1
    CODELINE1 30
    CODELINE2 30
    CODELINE3 3

    I did ti through VB but when i got the error i tried it threw queryanalyzer and got the sam
    Beyond Limitation

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Order of feilds has to be the same. Type and length of field could be different - if server can convert by itself with out loosing data (truncate).

  5. #5
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160
    do you happen to know a reason why this happens all sql databases or is it another "Microsoft Special Feature"

    any suggestiosn without me selcting teh order of columns to select fomr (50 columns and cna change any time)

    one way i have - but rather not do - is alter table accordingly
    Beyond Limitation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •