Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    84

    Unanswered: Inserting values into a column by selecting value from different table

    Hi, I have a question regarding how to insert one column values into a table by selecting from different table..Here is the syntax..
    ------------
    insert into propertytable values (select lastvalue+incrementby from agilesequences where name='SEQPROPERTYTABLE', 13926, 0, 4, 1, 451, 1, 8, 1)

    the first column in the propertytable will be... select lastvalue+incrementby from agilesequences where name='SEQPROPERTYTABLE'
    How do I do that..Help PLZ..
    Kishore

  2. #2
    Join Date
    May 2004
    Posts
    2
    There are probably a number of ways to accomplish this...my preference would be to use a local variable to hold the value.

    declare @seq varchar(20); --[whatever...could be int]

    select @seq = lastvalue+incrementby
    from agilesequences
    where name='SEQPROPERTYTABLE';

    insert into propertytable values (@seq, 13926, 0, 4, 1, 451, 1, 8, 1);

    --------------------------
    This should work unless I fat-fingered something.
    There may be a way to do this in one pop...
    --------------------------

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    INSERT INTO propertytable(ColName) 
    SELECT lastvalue+incrementby 
      FROM agilesequences 
     WHERE name='SEQPROPERTYTABLE'
    What's this?

    13926, 0, 4, 1, 451, 1, 8, 1


    And You should supply a collist for the inserted tables...

    Damn another fluff reply...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Mar 2004
    Posts
    84
    Quote Originally Posted by ajsims
    There are probably a number of ways to accomplish this...my preference would be to use a local variable to hold the value.

    declare @seq varchar(20); --[whatever...could be int]

    select @seq = lastvalue+incrementby
    from agilesequences
    where name='SEQPROPERTYTABLE';

    insert into propertytable values (@seq, 13926, 0, 4, 1, 451, 1, 8, 1);

    --------------------------
    This should work unless I fat-fingered something.
    There may be a way to do this in one pop...
    --------------------------
    Thanks a lot guys..
    This worked for me.
    Kishore

Posting Permissions

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