Procedure

  • How to create a dynamic procedure to insert multiple data into two or more tables

  • Can you explain the requirements in more detail please?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • This is the best I could do with the vague question you posted:

    Create Procedure Give_More_Details

    @Table1 varchar(10),

    @Table2 varchar(10),

    @Col1 varchar(10),

    @Col2 varchar(10),

    @Data1 varchar(max),

    @Data2 varchar(max)

    As

    Declare

    @query1 varchar(max),

    @query2 varchar(max)

    Begin

    Set @query1 = 'Insert Into '+@Table1+'('+@Col1+') Values('''+@Data1+''');'

    Set @query2 = 'Insert Into '+@Table2+'('+@Col2+') Values('''+@Data2+''');'

    Exec (@query1)

    Exec (@query2)

    End

    Hope this helps. If not then please read the name of the procedure.:-P:-D

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

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

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