Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Location
    Ireland
    Posts
    181

    Unanswered: insert into one table from another

    Hi,

    Is there a way (I know there probably is but I'm not getting it) of
    inserting into one table from another along the lines

    insert into tableA values (select * from tableB)

    without using bcp?

    Thanks for any help,
    Breen.

  2. #2
    Join Date
    Jun 2003
    Posts
    15

    Re: insert into one table from another

    Originally posted by Breen
    Hi,

    Is there a way (I know there probably is but I'm not getting it) of
    inserting into one table from another along the lines

    insert into tableA values (select * from tableB)

    without using bcp?

    Thanks for any help,
    Breen.

    Yes, you were close!
    The syntax is:
    insert into tableA
    select * from tableB

    tableA must exist with the same column names and attributes as tableB.

    You could also specify a column list assuming some columns allow nulls.
    i.e :
    insert tableA values(f1,f3)
    select f1,f3 from tableC
    (assumes f2 allows nulls)

    You could also use selection criteria:
    insert tableA
    select * from tableC where f1 > 5

  3. #3
    Join Date
    Jun 2003
    Posts
    15

    Re: insert into one table from another

    Originally posted by kendsr
    Yes, you were close!
    The syntax is:
    insert into tableA
    select * from tableB

    tableA must exist with the same column names and attributes as tableB.

    You could also specify a column list assuming some columns allow nulls.
    i.e :
    insert tableA values(f1,f3)
    select f1,f3 from tableC
    (assumes f2 allows nulls)

    You could also use selection criteria:
    insert tableA
    select * from tableC where f1 > 5
    ooopppps! above "values" should not be there. Sorry!

  4. #4
    Join Date
    Mar 2002
    Location
    Ireland
    Posts
    181
    Thanking you kendsr.

    Rgs,
    Breen.

Posting Permissions

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