inserting the selected record from from one table to another

  • Create procedure add193instock(

    @trnno int,

    @isin varchar(15),

    @debit int,

    @credit int,

    @desribe varchar(50),

    @isinname varchar(50),

    @clientid int

    )

    as

    begin

    insert into row1.stock

    (

    trnno,

    isin,

    debit,

    credit,

    desribe,

    isinname,

    clientid

    )

    from row1.mytable193

    (

    Column68,

    column61,

    Column72,

    Column70,

    Column69,

    Column62,

    substring(Column69,1,20)

    )

    end

  • What is your question?

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • In the future pleas write your question. In this case you had an error in your code that is very easy to spot, so I think that I can guess your question – “why do I get an error when I try to create the fallowing procedure?”

    In your code you are trying to run an insert select statement. An insert select statement should look like this:

    INSERT INTO TargetTable (Col1, Col2)

    SELECT ColA, ColB

    FROM SourceDB.dbo.Source table

    In your code you misplaced the FROM clause and completely forgot the SELECT clause.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

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

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